I am using mongoskin in nodejs for db queries.
I am not able to use cursor on aggregate query whereas in case of find query it is working fine.
//This code is working fine
var cursor = db.collection('users').find();
cursor.forEach(function(user){
console.log(user);
})
//The below query is not working
var cursor = db.collection('users').aggregate([{$sort:{username:1}}]);
cursor.forEach(function(user){
console.log(user);
})
//error - cursor.forEach is not a function
Is there any alternate way of using a cursor on aggregation using mongoskin?
"mongoskin": "^2.1.0"
I had the same issue. i created a library for it. which allows to write foreach with aggregate and could run with cursor. mongoskin-cursor
Example: db.collection('collectionname').aggregate().forEach(function(){}); db.collection('collectionname').aggregateAsync().then(function(){});