Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var MongoClient = require('mongodb').MongoClient;
- MongoClient.connect('mongodb://localhost:27017/school', function(err, db){
- if (err) throw err;
- var students = db.collection('students');
- var cursor = students.find({'scores.type':'homework'});
- cursor.sort('score', 1);
- cursor.each()(function(err, doc){
- if(err) throw err;
- console.dir(doc);
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement