Skip to content

Instantly share code, notes, and snippets.

@heymichaelp
Last active August 29, 2015 14:03
Show Gist options
  • Save heymichaelp/7261c60c031af10b2cd6 to your computer and use it in GitHub Desktop.
Save heymichaelp/7261c60c031af10b2cd6 to your computer and use it in GitHub Desktop.
Query Objects: Example Pre-Query Object
var MongoClient = require('mongodb').MongoClient
var createStudentQuery = function(student, callback) {
MongoClient.connect('mongodb://127.0.0.1:27017/test', function(err, db) {
if (err) throw err;
var collection = db.collection('students');
collection.insert(student, function(err, docs) {
collection.find().toArray(function(err, result) {
db.close();
callback(result);
});
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment