Below is the code uses mongoskin for mongodb access with nodejs. How do i access the callback function return value from the outside?
app.get('/', function(req, res) {
var ret = db.collection('counters').findAndModify(
{_id: 'messagetransaction'},
[],
{$inc : {next: 1}},
true,
true,
function(err, counter) {
if (err) {
throw err;
}else{
console.log(counter.next);
return counter.next;
}
}
);
});
console.log(ret);
I got the error as below,
ReferenceError: ret is not defined
Please help me on this!