0% found this document useful (0 votes)
9 views1 page

Essential MongoDB Commands Guide

This document provides a list of basic MongoDB commands categorized by their actions, such as starting the shell, managing databases and collections, inserting, querying, updating, and deleting documents. Each command is presented in a concise format for easy reference. It serves as a quick guide for users to perform essential MongoDB operations.

Uploaded by

Sreemita Dey
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

Essential MongoDB Commands Guide

This document provides a list of basic MongoDB commands categorized by their actions, such as starting the shell, managing databases and collections, inserting, querying, updating, and deleting documents. Each command is presented in a concise format for easy reference. It serves as a quick guide for users to perform essential MongoDB operations.

Uploaded by

Sreemita Dey
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Basic MongoDB Commands

Category Action Command

Start MongoDB Shell Start MongoDB mongo

Database Show databases show dbs

Database Use/select a database use myDatabase

Database Show current database db

Database Drop/delete database [Link]()

Collection Show collections show collections

Collection Create collection [Link]("myCollection")

Collection Drop collection [Link]()

Insert Insert one document [Link]({ name: "Alice", age: 25 })

Insert Insert many documents [Link]([{ name: "Bob" }, { name: "Carol"

Query Find all documents [Link]()

Query Find with condition [Link]({ age: 25 })

Query Find one document [Link]({ name: "Alice" })

Query Pretty print [Link]().pretty()

Update Update one [Link]({ name: "Alice" }, { $set: { age: 2

Update Update many [Link]({ age: 25 }, { $set: { status: "ac

Update Replace document [Link]({ name: "Bob" }, { name: "Bobby

Delete Delete one [Link]({ name: "Carol" })

Delete Delete many [Link]({ age: 25 })

Other Count documents [Link]()

Other Limit results [Link]().limit(5)

Other Sort results [Link]().sort({ age: 1 })

You might also like