Skip to content

Instantly share code, notes, and snippets.

@shrawanx
Created March 18, 2017 13:37
Show Gist options
  • Save shrawanx/6a4d73ada564d87703c04034b217e412 to your computer and use it in GitHub Desktop.
Save shrawanx/6a4d73ada564d87703c04034b217e412 to your computer and use it in GitHub Desktop.
Mongodb basic usuage
service mongod start
service mongod stop
service mongod restart
show dbs --->will show all database
use [database name]---->will use the db
db.dropDatabase() ---> will drop database of selected database or else test db is deleted
db.createCollection([collection_name])---->will create a new collection
show collections ----> will show all collection inside the database
db.[collection_name].drop()------>will drop the collection
db.COLLECTION_NAME.insert(document)---->will insert document in collection
db.COLLECTION_NAME.find()---> finding document
db.COLLECTION_NAME.find().pretty()---->show result in formatted order
>db.COLLECTION_NAME.update(SELECTION_CRITERIA, UPDATED_DATA)-->updating
>db.COLLECTION_NAME.remove(DELLETION_CRITTERIA)-->deleting document
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment