June 2014
Intermediate to advanced
696 pages
38h 52m
English
You must create a collection in the MongoDB database before you can begin storing documents in it. To create a collection, you need to call createCollection(name, [options]) on the database handle. The name parameter is the name of the new collection. The optional options parameter is an object that can have the properties listed in Table 12.4, which define the behavior of the collection.
Table 12.4 Options that can be specified when creating a collection
For example, the following line of code creates a new collection called newCollection in the testDB database, as shown in Figure 12.7:
db.createCollection("newCollection") ...
Read now
Unlock full access