MongoDb Cheat Sheet for use with mongo shell.

System

Open

mongo

Satabases

List

show dbs

Open

use [DB NAME]

Collections

Create

db.createCollection("[COLLECTION NAME]")

Show

show collections

Records

Insert

db.[COLLECTION NAME].insert({item: "one", value: 1})

Insert with date

db.[COLLECTION NAME].insert({item: "one", value: 1, created: new Date()})

Select

db.[COLLECTION NAME].find()

Select with nice output

db.[COLLECTION NAME].find().pretty()

Get users on admin table

db.getUsers()
Marcin Narloch

Marcin Narloch

Creative and out-of-the-box thinker with strong interests and knowledge in technology and innovation.
Reset Git Branch Commits Previous post cURL with Bash Cheat Sheet
Reset Git Branch Commits Next post Helm Cheat Sheet

Leave a Reply

Your email address will not be published. Required fields are marked *