MongoDB part-2
# Commands / Codes / Query :
1. Create Database
MongoDB creates a database when you first store data in it. You can switch to a database using the use
command.
2. Drop Database
To drop a database, you can use the following command:
3. Create Collection
You can create a collection by inserting a document into it. However, you can also use the createCollection
method.
4. Drop Collection
To drop a collection, use:
5. Rename Collection
To rename a collection, use:
6. Insert Documents in the Collection
You can insert one or multiple documents:
7. Delete Documents
To delete documents, you can use deleteOne
or deleteMany
:
8. Update Document/Data
To update documents, you can use updateOne
or updateMany
: