June 2014
Intermediate to advanced
696 pages
38h 52m
English
The Collection object represents a collection in the MongoDB database. You use the Collection object to access items in the collection, add documents, query documents, and much more.
You can get a Collection object by using the collection() method on an instance of the Db object or by passing a Db object and collection name to the constructor. If the collection isn’t already created on the MongoDB server, you can create it by using the createCollection() method on the Db object. For example, all of the following work:
var collection = db.collection()var collection = new Collection(db, "myCollection")db.createCollection("newCollection", function(err, collection){ }
Table 13.7 lists ...
Read now
Unlock full access