Thursday, January 3, 2019

Remove


1. Remove document of specified pattern

JSON data in Collection -
{ "_id" : ObjectId("5c2e4c15a11d440854f7553d"), "A" : "Apple", "B" : "Banana" }

=====> > db.esawal.remove({A: "Apple"})
WriteResult({ "nRemoved" : 1 })


2.

Update


Short Note of Query

1. Create Collection

======> use db_name

Note - db_name == collection name

2. Show All Database

======> show dbs

3. Show particular db data

======> db.db_name.find()

4. Insert Data in DB

======> db.db_name.insert({"Name":"XYZ"})

5. Show All Collection

======> Show Collections

6. Create Collection

======> db.createcollections("XYZ")

7. Drop collection XYZ

======>db.XYZ.drop()

8. Drop collection "XYZ Test", if contain white space in collection name

======> db.["XYZ Test"].drop()