Last active
August 29, 2015 14:03
-
-
Save heymichaelp/7261c60c031af10b2cd6 to your computer and use it in GitHub Desktop.
Query Objects: Example Pre-Query Object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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