In MongoDB a collection is automatically created when it is referenced in any command. For example, if you run an insert command : db. student . insert ({ name : " Viraj " }) Above command will create a collection named student if it doesn't exist already in the database. But we can explicitly create a collection using the createCollection() command. The syntax of createCollection method is : db. createCollection ( name , options ) In the above command, name will be the name of the collection and options is a document which can be used to specify configurations for the collection. options parameter is optional, and you can simply create a collection by just providing a name for the collection. But if you want to configure your collection, you can use various options available to do so. Following are the available configuration options for creating a collection in MongoDB : Field Type Description capped boolean (Option...
Comments
Post a Comment