Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save peter-avila/52c2fdd6d0376dc3b31b5acd2753d835 to your computer and use it in GitHub Desktop.
Save peter-avila/52c2fdd6d0376dc3b31b5acd2753d835 to your computer and use it in GitHub Desktop.

Revisions

  1. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ This section is broken down into 5 sub-sections. The first 4 match the CRUD Verb
    Couple notes here:

    1. All of these commands start with `db.<collection>` where `<collection>` is the name of the collection you want to call these methods on. Any exceptions will be noted in the description.**
    2. `{query}` Is referring to queries like `{<field>: '<value>', <field>:'<value>', etc)`. IE: `{ publisher: 'Under The Bleacher', author: 'I. Seymor Rumps', etc}`. They are field-value pairs that are used to make documents, and also used during searches, aka queries.
    2. `{query}` Is referring to queries like `{<field>: '<value>', <field>:'<value>', etc)`. IE: `{ book: 'Golden River Doth Flows', author: 'I.P. Freely', etc}`. They are field-value pairs that are used to make documents, and also used during searches, aka queries.

    ### Create

  2. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 19 additions and 10 deletions.
    29 changes: 19 additions & 10 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -47,15 +47,19 @@ Rename | `db.<cllectn>.renameCollection('collection')` | Renames a collection. [

    ## Data

    This section is broken down into 5 sub-sections. The first 4 match the CRUD Verbs of Create, Read, Update, Delete, and the last one is a list of Combos like `findAndUpdate`.
    This section is broken down into 5 sub-sections. The first 4 match the CRUD Verbs of Create, Read, Update, Delete, and the last one is a list of Combos like `findAndUpdate`. Check here for the [Mongo Docs on Crud](https://docs.mongodb.com/manual/crud/)

    Couple notes here:

    1. All of these commands start with `db.<collection>` where `<collection>` is the name of the collection you want to call these methods on. Any exceptions will be noted in the description.**
    2. `{query}` Is referring to queries like `{<field>: '<value>', <field>:'<value>', etc)`. IE: `{ publisher: 'Under The Bleacher', author: 'I. Seymor Rumps', etc}`. They are field-value pairs that are used to make documents, and also used during searches, aka queries.

    **NOTE: All of these commands start with `db.<collection>` where `<collection>` is the name of the collection you want to call these methods on. Any exceptions will be noted in the description.**
    ### Create

    Type | Command | Description
    :--- | :--- | :---
    Create One | `.insertOne(<document>)` | Inserts a document into the collection. IE: `db.cars.insertOne({make:"ford"})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.insertOne/#db.collection.insertOne)
    Create One/Many | `.insert([{},{}...)` | Inserts One or more documents into the collection. If an array is passed in it will make a record of each document in the array. Otherwise it will accept a single document. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.insert/#db.collection.insert)
    Create One | `.insertOne({<doc>})` | Inserts a document into the collection. IE: `db.cars.insertOne({make:"ford"})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.insertOne/#db.collection.insertOne)
    Create One/Many | `.insert([{<doc>},{<doc>},{<doc>}] )` | Inserts One or more documents into the collection. If an array is passed in it will make a record of each document in the array. Otherwise it will accept a single document. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.insert/#db.collection.insert)


    ### Read
    @@ -66,29 +70,34 @@ Type | Command | Description
    :--- | :--- | :---
    Count | `.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All Filtered| `.find({<field>:'<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `.findOne({<field>:'<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Useful when searching by unique fields like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)
    Return All Filtered| `.find({query})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `.findOne({query})` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Useful when searching by unique fields like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)

    ### Update

    Type | Command | Description
    :--- | :--- | :---
    Update/Replace | `.update({query}, {$set:{<field>:'<value>'}}, options)` | The first argument is used as the query to find the document. The second argument specifies which field which to update. Exclude `$set:` and the entire document will be Replaced. Common options: `upsert: <boolean>` to keep it unique, and `multi: <boolean>` will update multiple documents if set to true. [Docs](https://docs.mongodb.com/manual/reference/method/db.collection.update/#db.collection.update) and [Field Operator Docs](https://docs.mongodb.com/manual/reference/operator/update-field/)
    Update/Replace | `.update({query}, { $set: {query} }, options)` | The first argument is used as the query to find the document. The second argument specifies which field which to update. Exclude `$set:` and the entire document will be Replaced. Common options: `upsert: <boolean>` to keep it unique, and `multi: <boolean>` will update multiple documents if set to true. [Docs](https://docs.mongodb.com/manual/reference/method/db.collection.update/#db.collection.update) and [Field Operator Docs](https://docs.mongodb.com/manual/reference/operator/update-field/)
    Update One/Many | `.updateOne()` and `.updateMany()`| Basically the same as the above function, except the `multi: <boolean>` option is basically defaulted to `false` and `true`, and isnt' an allowed option that can be passed in. [One Doc](https://docs.mongodb.com/manual/reference/method/db.collection.updateOne/#db.collection.updateOne), [Many Doc](https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/#db.collection.updateMany)

    ### Delete

    Type | Command | Description
    :--- | :--- | :---
    Delete One | `.deleteOne({<field>:'<value>'})` | Deletes the first document that matches the query. Recommend to search by `_id` or another unique field. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.deleteOne/#db.collection.deleteOne)
    Delete Many/All | `.deleteMany({<field>:'<value>'})` | Deletes all records that match the query. Leave the query blank to delete all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.deleteMany/#db.collection.deleteMany)
    Delete One | `.deleteOne({query})` | Deletes the first document that matches the query. Recommend to search by `_id` or another unique field. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.deleteOne/#db.collection.deleteOne)
    Delete Many/All | `.deleteMany({query})` | Deletes all records that match the query. Leave the query blank to delete all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.deleteMany/#db.collection.deleteMany)


    ### Combos

    These are
    These are some combo commands that really just do the same thing as their base commands, but have a couple extra options.

    All of these can leave their `{query}` blank and it will find the first document and execute it's verb on that item.

    Command | Desctiption
    :--- | :---
    `.findOneAndDelete({query})` | Finds the first document that matches the query and deletes it. [Doc] https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndDelete/#db.collection.findOneAndDelete
    `.findOneAndUpdate({query}, {<update>}, {<options>})` | Finds the first document that matches the query in the first argument, and updates it using the second arguments. Has optional options as well. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndUpdate/#db.collection.findOneAndUpdate)
    `.findOneAndReplace({query}, {<replacement>}, {<options>})` | Finds and replaces the document that matches the query. `<replacement>` cannot use update operators. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndReplace/#db.collection.findOneAndReplace)


  3. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 17 additions and 0 deletions.
    17 changes: 17 additions & 0 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -75,3 +75,20 @@ Type | Command | Description
    :--- | :--- | :---
    Update/Replace | `.update({query}, {$set:{<field>:'<value>'}}, options)` | The first argument is used as the query to find the document. The second argument specifies which field which to update. Exclude `$set:` and the entire document will be Replaced. Common options: `upsert: <boolean>` to keep it unique, and `multi: <boolean>` will update multiple documents if set to true. [Docs](https://docs.mongodb.com/manual/reference/method/db.collection.update/#db.collection.update) and [Field Operator Docs](https://docs.mongodb.com/manual/reference/operator/update-field/)
    Update One/Many | `.updateOne()` and `.updateMany()`| Basically the same as the above function, except the `multi: <boolean>` option is basically defaulted to `false` and `true`, and isnt' an allowed option that can be passed in. [One Doc](https://docs.mongodb.com/manual/reference/method/db.collection.updateOne/#db.collection.updateOne), [Many Doc](https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/#db.collection.updateMany)

    ### Delete

    Type | Command | Description
    :--- | :--- | :---
    Delete One | `.deleteOne({<field>:'<value>'})` | Deletes the first document that matches the query. Recommend to search by `_id` or another unique field. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.deleteOne/#db.collection.deleteOne)
    Delete Many/All | `.deleteMany({<field>:'<value>'})` | Deletes all records that match the query. Leave the query blank to delete all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.deleteMany/#db.collection.deleteMany)


    ### Combos

    These are

    Command | Desctiption
    :--- | :---


  4. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -74,4 +74,4 @@ Return One Filtered | `.findOne({<field>:'<value>')` | Returns a document (not a
    Type | Command | Description
    :--- | :--- | :---
    Update/Replace | `.update({query}, {$set:{<field>:'<value>'}}, options)` | The first argument is used as the query to find the document. The second argument specifies which field which to update. Exclude `$set:` and the entire document will be Replaced. Common options: `upsert: <boolean>` to keep it unique, and `multi: <boolean>` will update multiple documents if set to true. [Docs](https://docs.mongodb.com/manual/reference/method/db.collection.update/#db.collection.update) and [Field Operator Docs](https://docs.mongodb.com/manual/reference/operator/update-field/)
    Update One/Many | `.updateOne()` and `updateMany`| Basically the same as the above function, except the `multi: <boolean>` option is basically defaulted to `false` and `true`, and isnt' an allowed option that can be passed in. [One Doc](https://docs.mongodb.com/manual/reference/method/db.collection.updateOne/#db.collection.updateOne), [Many Doc](https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/#db.collection.updateMany)
    Update One/Many | `.updateOne()` and `.updateMany()`| Basically the same as the above function, except the `multi: <boolean>` option is basically defaulted to `false` and `true`, and isnt' an allowed option that can be passed in. [One Doc](https://docs.mongodb.com/manual/reference/method/db.collection.updateOne/#db.collection.updateOne), [Many Doc](https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/#db.collection.updateMany)
  5. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -74,3 +74,4 @@ Return One Filtered | `.findOne({<field>:'<value>')` | Returns a document (not a
    Type | Command | Description
    :--- | :--- | :---
    Update/Replace | `.update({query}, {$set:{<field>:'<value>'}}, options)` | The first argument is used as the query to find the document. The second argument specifies which field which to update. Exclude `$set:` and the entire document will be Replaced. Common options: `upsert: <boolean>` to keep it unique, and `multi: <boolean>` will update multiple documents if set to true. [Docs](https://docs.mongodb.com/manual/reference/method/db.collection.update/#db.collection.update) and [Field Operator Docs](https://docs.mongodb.com/manual/reference/operator/update-field/)
    Update One/Many | `.updateOne()` and `updateMany`| Basically the same as the above function, except the `multi: <boolean>` option is basically defaulted to `false` and `true`, and isnt' an allowed option that can be passed in. [One Doc](https://docs.mongodb.com/manual/reference/method/db.collection.updateOne/#db.collection.updateOne), [Many Doc](https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/#db.collection.updateMany)
  6. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -73,4 +73,4 @@ Return One Filtered | `.findOne({<field>:'<value>')` | Returns a document (not a

    Type | Command | Description
    :--- | :--- | :---
    Update/Replace | `.update({query}, {$set:{<field>:'<value>'}}, options)` | The first argument is used as the query to find the document. The second argument specifies which field which to update. Exclude `$set:` and the entire document will be Replaced. Common options: `upsert: <boolean>` to keep it unique, and `multi: <boolean>` will update multiple documents if set to true. [Docs](https://docs.mongodb.com/manual/reference/method/db.collection.update/#db.collection.update) [Field Operator Docs](https://docs.mongodb.com/manual/reference/operator/update-field/)
    Update/Replace | `.update({query}, {$set:{<field>:'<value>'}}, options)` | The first argument is used as the query to find the document. The second argument specifies which field which to update. Exclude `$set:` and the entire document will be Replaced. Common options: `upsert: <boolean>` to keep it unique, and `multi: <boolean>` will update multiple documents if set to true. [Docs](https://docs.mongodb.com/manual/reference/method/db.collection.update/#db.collection.update) and [Field Operator Docs](https://docs.mongodb.com/manual/reference/operator/update-field/)
  7. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -43,13 +43,13 @@ List | `db.getCollectionNames()` | Lists all collections for a current Database.
    Return | `db.getCollection('<collection>')` | Returns a collection. Can chain methods onto it. IE `db.getCollection.('authors').find({})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.getCollection/)
    Return/Create | `db.<collection>` | Similar to `db.getCollection()`, but if the collection doesn't exist, then the collection will be return, but not added unless data is also added to that collection at the same time. IE: `db.items` does not add a collection to the database, but `db.items.insertOne({name: 'Mike'})` would, because data is also being added to the collection. Use `db.createCollection()` to add an empty collection. [Doc](https://docs.mongodb.com/manual/reference/method/js-collection/)
    Drop | `db.<collection>.drop()` | Drops the collection from the database. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.drop/#db.collection.drop)
    Rename | `db.<ccollection>.renameCollection('colletion')` | Renames a collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.renameCollection/#db.collection.renameCollection)
    Rename | `db.<cllectn>.renameCollection('collection')` | Renames a collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.renameCollection/#db.collection.renameCollection)

    ## Data

    This section is broken down into 5 sub-sections. The first 4 match the CRUD Verbs of Create, Read, Update, Delete, and the last one is a list of Combos like `findAndUpdate`.

    **NOTE:** All of these commands start with `db.<collection>` where `<collection>` is the name of the collection you want to call these methods on. Any exceptions will be noted in the description.
    **NOTE: All of these commands start with `db.<collection>` where `<collection>` is the name of the collection you want to call these methods on. Any exceptions will be noted in the description.**
    ### Create

    Type | Command | Description
  8. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -38,10 +38,10 @@ This Table lists the commands most commonly used when working with collections a

    Type | Command | Description
    :--- | :--- | :---
    Create | `db.createCollection('<name>)` | Creates a new empty collection in the database. [Doc](https://docs.mongodb.com/manual/reference/method/db.createCollection/#db.createCollection)
    Create | `db.createCollection('<collection>)` | Creates a new empty collection in the database. [Doc](https://docs.mongodb.com/manual/reference/method/db.createCollection/#db.createCollection)
    List | `db.getCollectionNames()` | Lists all collections for a current Database. [Doc](https://docs.mongodb.com/manual/reference/method/db.getCollectionNames/#db.getCollectionNames)
    Return | `db.getCollection('<name>')` | Returns a collection. Can chain methods onto it. IE `db.getCollection.('authors').find({})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.getCollection/)
    Return/Create | `db.<collection name>` | Similar to `db.getCollection()`, but if the collection doesn't exist, then the collection will be return, but not added unless data is also added to that collection at the same time. IE: `db.items` does not add a collection to the database, but `db.items.insertOne({name: 'Mike'})` would, because data is also being added to the collection. Use `db.createCollection()` to add an empty collection. [Doc](https://docs.mongodb.com/manual/reference/method/js-collection/)
    Return | `db.getCollection('<collection>')` | Returns a collection. Can chain methods onto it. IE `db.getCollection.('authors').find({})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.getCollection/)
    Return/Create | `db.<collection>` | Similar to `db.getCollection()`, but if the collection doesn't exist, then the collection will be return, but not added unless data is also added to that collection at the same time. IE: `db.items` does not add a collection to the database, but `db.items.insertOne({name: 'Mike'})` would, because data is also being added to the collection. Use `db.createCollection()` to add an empty collection. [Doc](https://docs.mongodb.com/manual/reference/method/js-collection/)
    Drop | `db.<collection>.drop()` | Drops the collection from the database. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.drop/#db.collection.drop)
    Rename | `db.<ccollection>.renameCollection('colletion')` | Renames a collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.renameCollection/#db.collection.renameCollection)

  9. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -54,7 +54,7 @@ This section is broken down into 5 sub-sections. The first 4 match the CRUD Verb

    Type | Command | Description
    :--- | :--- | :---
    Create One | `.insertOne(<document>)` | Inserts a document into the collection. IE: db.cars.insertOne({make:"ford"}). [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.insertOne/#db.collection.insertOne)
    Create One | `.insertOne(<document>)` | Inserts a document into the collection. IE: `db.cars.insertOne({make:"ford"})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.insertOne/#db.collection.insertOne)
    Create One/Many | `.insert([{},{}...)` | Inserts One or more documents into the collection. If an array is passed in it will make a record of each document in the array. Otherwise it will accept a single document. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.insert/#db.collection.insert)


  10. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -49,7 +49,7 @@ Rename | `db.<ccollection>.renameCollection('colletion')` | Renames a collection

    This section is broken down into 5 sub-sections. The first 4 match the CRUD Verbs of Create, Read, Update, Delete, and the last one is a list of Combos like `findAndUpdate`.

    All of these commands start with `db.<collection>` where `<collection>` is the name of the collection you want to call these methods on. Any exceptions will be noted in the description.
    **NOTE:** All of these commands start with `db.<collection>` where `<collection>` is the name of the collection you want to call these methods on. Any exceptions will be noted in the description.
    ### Create

    Type | Command | Description
  11. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 8 additions and 7 deletions.
    15 changes: 8 additions & 7 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -49,12 +49,13 @@ Rename | `db.<ccollection>.renameCollection('colletion')` | Renames a collection

    This section is broken down into 5 sub-sections. The first 4 match the CRUD Verbs of Create, Read, Update, Delete, and the last one is a list of Combos like `findAndUpdate`.

    All of these commands start with `db.<collection>` where `<collection>` is the name of the collection you want to call these methods on. Any exceptions will be noted in the description.
    ### Create

    Type | Command | Description
    :--- | :--- | :---
    Create One | `db.<collection>.insertOne(<document>)` | Inserts a document into the collection. IE: db.cars.insertOne({make:"ford"}). [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.insertOne/#db.collection.insertOne)
    Create One/Many | `db.<collection>.insert([{},{}...)` | Inserts One or more documents into the collection. If an array is passed in it will make a record of each document in the array. Otherwise it will accept a single document. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.insert/#db.collection.insert)
    Create One | `.insertOne(<document>)` | Inserts a document into the collection. IE: db.cars.insertOne({make:"ford"}). [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.insertOne/#db.collection.insertOne)
    Create One/Many | `.insert([{},{}...)` | Inserts One or more documents into the collection. If an array is passed in it will make a record of each document in the array. Otherwise it will accept a single document. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.insert/#db.collection.insert)


    ### Read
    @@ -63,13 +64,13 @@ Most of these commands allow methods to be chained onto them.

    Type | Command | Description
    :--- | :--- | :---
    Count | `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `db.<collection>.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All Filtered| `db.<collection>.find({<field>:'<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `db.<collection>.findOne({<field>:'<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Useful when searching by unique fields like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)
    Count | `.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All Filtered| `.find({<field>:'<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `.findOne({<field>:'<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Useful when searching by unique fields like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)

    ### Update

    Type | Command | Description
    :--- | :--- | :---
    Update/Replace | `db.<collection>.update( {query}, {$set:{<field>:'<value>'} }, options)` | The first argument is used as the query to find the document. The second argument specifies which field which to update. Exclude `$set:` and the entire document will be Replaced. Common options: `upsert: <boolean>` to keep it unique, and `multi: <boolean>` will update multiple documents if set to true. [Docs](https://docs.mongodb.com/manual/reference/method/db.collection.update/#db.collection.update) [Field Operator Docs](https://docs.mongodb.com/manual/reference/operator/update-field/)
    Update/Replace | `.update({query}, {$set:{<field>:'<value>'}}, options)` | The first argument is used as the query to find the document. The second argument specifies which field which to update. Exclude `$set:` and the entire document will be Replaced. Common options: `upsert: <boolean>` to keep it unique, and `multi: <boolean>` will update multiple documents if set to true. [Docs](https://docs.mongodb.com/manual/reference/method/db.collection.update/#db.collection.update) [Field Operator Docs](https://docs.mongodb.com/manual/reference/operator/update-field/)
  12. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -72,5 +72,4 @@ Return One Filtered | `db.<collection>.findOne({<field>:'<value>')` | Returns a

    Type | Command | Description
    :--- | :--- | :---

    Update/Replace | `db.<collection>.update( {query}, {$set:{<field>:'<value>'} }, options)` | The first argument is used as the query to find the document. The second argument specifies which field which to update. Exclude `$set:` and the entire document will be Replaced. Common options: `upsert: <boolean>` to keep it unique, and `multi: <boolean>` will update multiple documents if set to true. [Docs](https://docs.mongodb.com/manual/reference/method/db.collection.update/#db.collection.update) [Field Operator Docs](https://docs.mongodb.com/manual/reference/operator/update-field/)
  13. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 20 additions and 2 deletions.
    22 changes: 20 additions & 2 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -43,16 +43,34 @@ List | `db.getCollectionNames()` | Lists all collections for a current Database.
    Return | `db.getCollection('<name>')` | Returns a collection. Can chain methods onto it. IE `db.getCollection.('authors').find({})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.getCollection/)
    Return/Create | `db.<collection name>` | Similar to `db.getCollection()`, but if the collection doesn't exist, then the collection will be return, but not added unless data is also added to that collection at the same time. IE: `db.items` does not add a collection to the database, but `db.items.insertOne({name: 'Mike'})` would, because data is also being added to the collection. Use `db.createCollection()` to add an empty collection. [Doc](https://docs.mongodb.com/manual/reference/method/js-collection/)
    Drop | `db.<collection>.drop()` | Drops the collection from the database. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.drop/#db.collection.drop)
    Rename | `db.<ccollection>.renameCollection('colletion')` | Renames a collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.renameCollection/#db.collection.renameCollection)

    ## Data

    This section is broken down into 4 sections that match the Crud Verbs of Create, Read, Update, Delete. Each table lists the commands most commonly used when working with data inside collections as it pertains to its verb.
    This section is broken down into 5 sub-sections. The first 4 match the CRUD Verbs of Create, Read, Update, Delete, and the last one is a list of Combos like `findAndUpdate`.

    ### Create

    Type | Command | Description
    :--- | :--- | :---
    Create One | `db.<collection>.insertOne(<document>)` | Inserts a document into the collection. IE: db.cars.insertOne({make:"ford"}). [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.insertOne/#db.collection.insertOne)
    Create One/Many | `db.<collection>.insert([{},{}...)` | Inserts One or more documents into the collection. If an array is passed in it will make a record of each document in the array. Otherwise it will accept a single document. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.insert/#db.collection.insert)


    ### Read

    Most of these commands allow methods to be chained onto them.

    Type | Command | Description
    :--- | :--- | :---
    Count | `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `db.<collection>.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All Filtered| `db.<collection>.find({<field>:'<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `db.<collection>.findOne({<field>:'<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)
    Return One Filtered | `db.<collection>.findOne({<field>:'<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Useful when searching by unique fields like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)

    ### Update

    Type | Command | Description
    :--- | :--- | :---

    Update/Replace | `db.<collection>.update( {query}, {$set:{<field>:'<value>'} }, options)` | The first argument is used as the query to find the document. The second argument specifies which field which to update. Exclude `$set:` and the entire document will be Replaced. Common options: `upsert: <boolean>` to keep it unique, and `multi: <boolean>` will update multiple documents if set to true. [Docs](https://docs.mongodb.com/manual/reference/method/db.collection.update/#db.collection.update) [Field Operator Docs](https://docs.mongodb.com/manual/reference/operator/update-field/)
  14. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -54,5 +54,5 @@ Type | Command | Description
    :--- | :--- | :---
    Count | `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `db.<collection>.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All/Filtered | `db.<collection>.find({<field>:'<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All Filtered| `db.<collection>.find({<field>:'<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `db.<collection>.findOne({<field>:'<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)
  15. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ This section is broken down into 4 sections that match the Crud Verbs of Create,

    Type | Command | Description
    :--- | :--- | :---
    Count | `db.collection.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `db.collection.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All/Filtered | `db.collection.find({ <field>: '<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `db.collection.findOne({ <field>: '<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)
    Count | `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `db.<collection>.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All/Filtered | `db.<collection>.find({<field>:'<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `db.<collection>.findOne({<field>:'<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)
  16. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -52,8 +52,7 @@ This section is broken down into 4 sections that match the Crud Verbs of Create,

    Type | Command | Description
    :--- | :--- | :---
    Count | `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `db.<collection>.find({})` | Returns an array of all items in a collection.
    `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All/Filtered | `db.<collection>.find({ <field>: '<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)
    Count | `db.collection.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `db.collection.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All/Filtered | `db.collection.find({ <field>: '<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `db.collection.findOne({ <field>: '<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)
  17. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -53,6 +53,7 @@ This section is broken down into 4 sections that match the Crud Verbs of Create,
    Type | Command | Description
    :--- | :--- | :---
    Count | `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `db.<collection>.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All | `db.<collection>.find({})` | Returns an array of all items in a collection.
    `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All/Filtered | `db.<collection>.find({ <field>: '<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)
  18. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 0 additions and 14 deletions.
    14 changes: 0 additions & 14 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -56,17 +56,3 @@ Count | `db.<collection>.count()` | Returns the number of items in the collectio
    Return All | `db.<collection>.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All/Filtered | `db.<collection>.find({ <field>: '<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)

    <table>
    <tr>
    <th colspan=2>Type</th>
    <th>Command</th>
    <th>Description</th>
    </tr>
    <tr>
    <td colspan=2>Count</td>
    <td>db.<collection>.count()</td>
    <td>Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)</td>
    </tr>
    </table>

  19. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -59,12 +59,12 @@ Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns

    <table>
    <tr>
    <th>Type</th>
    <th colspan=2>Type</th>
    <th>Command</th>
    <th>Description</th>
    </tr>
    <tr>
    <td>Count</td>
    <td colspan=2>Count</td>
    <td>db.<collection>.count()</td>
    <td>Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)</td>
    </tr>
  20. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -64,7 +64,7 @@ Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns
    <th>Description</th>
    </tr>
    <tr>
    <td colspan=2>Count</td>
    <td>Count</td>
    <td>db.<collection>.count()</td>
    <td>Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)</td>
    </tr>
  21. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -59,13 +59,12 @@ Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns

    <table>
    <tr>
    <th colspan=2>Type</th>
    <th>Type</th>
    <th>Command</th>
    <th>Description</th>
    </tr>
    <tr>
    <td>Count</td>
    <td></td>
    <td colspan=2>Count</td>
    <td>db.<collection>.count()</td>
    <td>Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)</td>
    </tr>
  22. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -65,7 +65,8 @@ Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns
    </tr>
    <tr>
    <td>Count</td>
    <td>`db.<collection>.count()`</td>
    <td></td>
    <td>db.<collection>.count()</td>
    <td>Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)</td>
    </tr>
    </table>
  23. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -63,5 +63,10 @@ Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns
    <th>Command</th>
    <th>Description</th>
    </tr>
    <tr>
    <td>Count</td>
    <td>`db.<collection>.count()`</td>
    <td>Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)</td>
    </tr>
    </table>

  24. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -59,8 +59,8 @@ Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns

    <table>
    <tr>
    <th>Type</th>
    <th>Command></th>
    <th colspan=2>Type</th>
    <th>Command</th>
    <th>Description</th>
    </tr>
    </table>
  25. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 9 additions and 3 deletions.
    12 changes: 9 additions & 3 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -55,7 +55,13 @@ Type | Command | Description
    Count | `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `db.<collection>.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All/Filtered | `db.<collection>.find({ <field>: '<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return-One-Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)


    Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)

    <table>
    <tr>
    <th>Type</th>
    <th>Command></th>
    <th>Description</th>
    </tr>
    </table>

  26. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -52,10 +52,10 @@ This section is broken down into 4 sections that match the Crud Verbs of Create,

    Type | Command | Description
    :--- | :--- | :---
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Count &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Count | `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `db.<collection>.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All/Filtered | `db.<collection>.find({ <field>: '<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)
    Return-One-Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)



  27. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ This section is broken down into 4 sections that match the Crud Verbs of Create,

    Type | Command | Description
    :--- | :--- | :---
    Count &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Count &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `db.<collection>.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All/Filtered | `db.<collection>.find({ <field>: '<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)
  28. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ This section is broken down into 4 sections that match the Crud Verbs of Create,

    Type | Command | Description
    :--- | :--- | :---
    Count &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Count &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `db.<collection>.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All/Filtered | `db.<collection>.find({ <field>: '<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)
  29. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ This section is broken down into 4 sections that match the Crud Verbs of Create,

    Type | Command | Description
    :--- | :--- | :---
    Count &nbsp; &nbsp; &nbsp;| `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Count &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `db.<collection>.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All/Filtered | `db.<collection>.find({ <field>: '<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)
  30. @michaeltreat michaeltreat revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mongodb_shell_commands.md
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ This section is broken down into 4 sections that match the Crud Verbs of Create,

    Type | Command | Description
    :--- | :--- | :---
    Count &nbsp &nbsp &nbsp| `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Count &nbsp; &nbsp; &nbsp;| `db.<collection>.count()` | Returns the number of items in the collection. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count)
    Return All | `db.<collection>.find({})` | Returns an array of all items in a collection. `.find()` Must be passed `{}` in order to return all documents. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return All/Filtered | `db.<collection>.find({ <field>: '<value>'})` | Returns an array of items in a collection that match the query passed into `.find()`. See [Query and Project Operators](https://docs.mongodb.com/manual/reference/operator/query/) for extra info on querys. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)
    Return One Filtered | `db.<collection>.findOne({ <field>: '<value>')` | Returns a document (not an array) of the first item found, filtering based off what was passed into `.findOne()`. Usefuly when searching by unique field like `_id`, IE `db.cars.findOne({_id: 1})`. [Doc](https://docs.mongodb.com/manual/reference/method/db.collection.findOne/#db.collection.findOne)