June 2014
Intermediate to advanced
696 pages
38h 52m
English
Typically, you insert documents in a collection through your Node.js application. However, there may be times when you need to manually insert a document from an administrative point of view to preload a database, fix a database, or for testing purposes.
To add documents to a collection, you need to get the collection object and then call the insert(document) or save(document) method on that object. The document parameter is a well-formatted JavaScript object that is converted to BSON and stored in the collection. For example, the following commands create three new documents inside a collection, as shown in Figure 12.10:
use testDBcoll = db.getCollection("newCollection")coll.find() ...
Read now
Unlock full access