Below is code to retrieve all documents in collection.
db.collection('movies', function(err, collectionref) {
// find all documents in a collection that have foo: "bar"
var cursor = collectionref.find({});
cursor.toArray(function(err, docs) {
// gets executed once all items are retrieved
res.render('movie', {'movies': docs});
});
});
I want the id of all documents in collection using node js.