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.
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")