Skip to content

Instantly share code, notes, and snippets.

@darkcheftar
Created October 21, 2020 12:34
Show Gist options
  • Select an option

  • Save darkcheftar/79f55eb4c40e25aaf4a0bf2835dc6cc7 to your computer and use it in GitHub Desktop.

Select an option

Save darkcheftar/79f55eb4c40e25aaf4a0bf2835dc6cc7 to your computer and use it in GitHub Desktop.

Revisions

  1. darkcheftar created this gist Oct 21, 2020.
    23 changes: 23 additions & 0 deletions Mongo.db.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    | s.no | command | description |
    | :--: | -------------------------------------- | ------------------------------------------------------------ |
    | 1 | db.help() | help on db method |
    | 2 | db.<collection_name>.help() | help on collection methods |
    | 3 | sh.help() | Sharding helpers |
    | 4 | rs.help() | replica set help |
    | 5 | help admin | adminstrative help |
    | 6 | help connect | connection to a db help |
    | 7 | help keys | key shortcuts |
    | 8 | help misc | miscellenous thing to know |
    | 9 | help mr | mapreduce |
    | 10 | show dbs | show databases names |
    | 11 | show collections | shows collection in the current db |
    | 12 | show users | show users in current db |
    | 13 | show profile | show most recent system.profile |
    | 14 | show logs | show the accessible logger names |
    | 15 | show log <name> | prints out the last segment of log in memory, ‘global’ is default |
    | 16 | use <db_name> | set current database |
    | 17 | db.<collection_name>.find() | list objects in collection <collection_name> |
    | 18 | db.<collection_name>.find({a:1}) | list objects in <collection_name> where a == 1 |
    | 19 | it | result of the last line evaluated; use to further iterate |
    | 20 | DBQuery.shellBatchSize = x | set default number of items to display on shell |
    | 21 | exit | quit the mongo shell |