In my node application i am using mongodb for datastorage by using Mongoose.In that the following is my code:
var client = new OAuthClient({"name":"default"});
client.user = req.user;
client.username = req.body.username;
console.log("b4 save");
client.save();
OAuthClient.find({username:req.body.username}).exec(function(err, clients) {
if (err) {
res.render('error', {
status: 500
});
} else {
console.log("clientssssssss=" + util.inspect(clients));
res.jsonp(clients);
}
});
But
console.log("clientssssssss=" + util.inspect(clients)); Is returning empty array[].
while i execute the command in my ROBOMONGO the result is returned. suppose consider my query is like this OAuthClient.find({username:'user4'})
the result is coming, but with the above code its returning empty array. Help me to solve this. Thanks in advance..