I have the following, & im using it to log in and do a query, so I get through db.authenticate
, but when I do my query I get thrown:
MongoError: unauthorized data ns:data.data lock type:0 client:127.0.0.1] name: 'MongoError' }
As ridiculous as the code block below may seem with all the nesting, i guess thats javascript's only flaw.
Db.open(function(err, db) {
if(!err) {
db.authenticate("admin", "1234", function(authdb, err) {
if(!err) { //YAY I LOG IN!!!
db.collection('data', function(err, collection) {
collection.findOne({'id':'1'}, function(err, item) {
if(err) { //What?!? I AM logged in
db.close();
console.log(err);
}
} );
} );
}
} ); //Sad face
}
});
How comes I can authenticate but I can't run the findOne
query? If I try the same with the same user in the mongo shell it goes through.