June 2015
Intermediate to advanced
192 pages
4h 8m
English
Being able to insert documents wouldn't do you much good if you didn't have a way to search for documents. MongoDB lets you specify a template on which to match, and returns objects matching that template.
As with insertions and updates, you'll work with a collection of documents, invoking the collection's find method.
Here's an example that finds all documents in the test collection with a call of kf6gpe-7 and prints them to the console:
var mongo = require('mongodb').MongoClient; var url = 'mongodb://localhost:27017/test'; mongo.connect(url, function(error, db) { console.log("mongo.connect returned " + error); var cursor = collection.find({call: 'kf6gpe-7'}); cursor.toArray(function(error, ...Read now
Unlock full access