Monday, 24 July 2017

Creation of Database and collection

the command to create a database is :

use <databasename>

note : Make sure that database name should not contain special characters because it effects the deployments of mongodb in various environments.

Creation of Collection :

Collection : it s a BSON Document (JSON like format).
simply its a collection of key value pairs.

For naming conventions : _ is used before the collection name.
while creating a collection there are certain parameters that's need to be passed, though they are optional , lets have a quick round of introduction to parameters.

Example : db.createCollection(<name of collection>, {
                                                                                       capped : <boolean>,
                                                                                        autoIndexId : <boolean>,
                                                                                        size: <number>,
                                                                                        max:<number>,
                                                                                        storageEngine:<document>,
                                                                                        validator: <document>,
                                                                                           validationLevel: <string>,
                                                                                          validationAction: <string>});


No comments:

Post a Comment