Skip to content

Instantly share code, notes, and snippets.

@alexhidalgo
Created January 20, 2016 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexhidalgo/2615773d4be7ad97abae to your computer and use it in GitHub Desktop.
Save alexhidalgo/2615773d4be7ad97abae to your computer and use it in GitHub Desktop.
MongoClient.connect('mongodb://localhost:27017/test', function (err, db) {
var query = {'company_code': 'biotech'}
var cursor = db.collection('companies').find(query)
cursor.forEach(
function (doc) {
console.log(doc.name + ' is a company')
},
function (err) {
assert.equal(err, null)
return db.close()
})
})
MongoClient.connect('mongodb://localhost:27017/test', function (err, db) {
var query = {'company_code': 'biotech'}
db.collection('companies').find(query).toArray(function (err, docs) {
docs.forEach(function (doc) {
console.log(doc.name + ' is a company')
})
db.close()
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment