MongoDB Basic Commands
1. show dbs -> for seeing your databases
2. database_name -> for creating a new database and switch to database
3. show collections -> for seeing databases collections
4. db.dropDatabase() -> for delete the database
5. db.createCollection('collection') -> for creating a collection
6. db.dropCollection('collection_name') -> for delete the collection
MongoDB CRUD Operations
CRUD Operations create, read, update and delete documents.
Create Operations :
Create or insert operations add new documents to a collection. If the collection does not currently exist, insert operations will create the collection.
MongoDB provides the following methods to insert documents into a collection:
db.collection.insertOne()New in version 3.2db.collection.insertMany()New in version 3.2
Read operations retrieve documents from a collection; i.e. query a collection for documents. MongoDB provides the following methods to read documents from a collection:
db.collection.updateOne()New in version 3.2db.collection.updateMany()New in version 3.2db.collection.replaceOne()New in version 3.2
db.collection.deleteOne()New in version 3.2db.collection.deleteMany()New in version 3.2
0 Comments