Skip to content

Instantly share code, notes, and snippets.

@danny-andrews
Last active July 14, 2021 21:16
Show Gist options
  • Save danny-andrews/3689df8abb5dbee9627ab08d89f7687c to your computer and use it in GitHub Desktop.
Save danny-andrews/3689df8abb5dbee9627ab08d89f7687c to your computer and use it in GitHub Desktop.

Revisions

  1. danny-andrews revised this gist Jul 14, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions mongodb-quickstart.md
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,7 @@

    ## Installation

    1. `$ brew tap mongodb/brew`
    1. `$ brew install mongodb-community` - Installs mongodb server on your machine.<sup id="1">[1](#f1)</sup>
    2. `$ brew services start mongodb-community` - Starts mongodb server locally.<sup id="2">[2](#f2)</sup>
    3. `$ npm install mongodb` - Installs mongodb node package.
  2. danny-andrews revised this gist Jul 14, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions mongodb-quickstart.md
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@

    db/mongo-config.js:
    ```js
    import { MongoClient } from "mongodb";
    const { MongoClient } = require("mongodb");

    const URI = "mongodb://localhost:27017/";

    @@ -32,7 +32,7 @@ const insertStuff = async () => {
    await client.close();
    };

    await insertStuff();
    insertStuff();

    ```

  3. danny-andrews revised this gist Jul 14, 2021. No changes.
  4. danny-andrews revised this gist Jul 14, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions mongodb-quickstart.md
    Original file line number Diff line number Diff line change
    @@ -42,6 +42,6 @@ await insertStuff();
    1. API Docs: https://mongodb.github.io/node-mongodb-native/4.0/
    1. Shell Docs: https://docs.mongodb.com/mongodb-shell/connect/#std-label-mdb-shell-connect

    <sup id="f1">[1](#1)</sup>Linux instructions [here](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/). [](#1)
    <sup id="f1">[1](#1)</sup>Linux instructions [here](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/).

    <sup id="f2">2</sup>By default, this will run on `localhost:27017`. [](#2)
    <sup id="f2">[2](#2)</sup>By default, this will run on `localhost:27017`.
  5. danny-andrews revised this gist Jul 14, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mongodb-quickstart.md
    Original file line number Diff line number Diff line change
    @@ -42,6 +42,6 @@ await insertStuff();
    1. API Docs: https://mongodb.github.io/node-mongodb-native/4.0/
    1. Shell Docs: https://docs.mongodb.com/mongodb-shell/connect/#std-label-mdb-shell-connect

    <sup id="f1">[](#1)</sup>Linux instructions [here](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/). [](#1)
    <sup id="f1">[1](#1)</sup>Linux instructions [here](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/). [](#1)

    <sup id="f2">2</sup>By default, this will run on `localhost:27017`. [](#2)
  6. danny-andrews revised this gist Jul 14, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mongodb-quickstart.md
    Original file line number Diff line number Diff line change
    @@ -42,6 +42,6 @@ await insertStuff();
    1. API Docs: https://mongodb.github.io/node-mongodb-native/4.0/
    1. Shell Docs: https://docs.mongodb.com/mongodb-shell/connect/#std-label-mdb-shell-connect

    <sup id="f1">1</sup>Linux instructions [here](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/). [](#1)
    <sup id="f1">[](#1)</sup>Linux instructions [here](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/). [](#1)

    <sup id="f2">2</sup>By default, this will run on `localhost:27017`. [](#2)
  7. danny-andrews revised this gist Jul 14, 2021. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions mongodb-quickstart.md
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,9 @@ const insertStuff = async () => {
    const db = client.db("fec");
    const collection = db.collection("items");
    await collection.insertOne({ name: "stuff" });

    // You have to close the connection, or the app will hang.
    // You'll probably want to do this in an afterAll hook in your tests.
    await client.close();
    };

  8. danny-andrews revised this gist Jul 14, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions mongodb-quickstart.md
    Original file line number Diff line number Diff line change
    @@ -40,4 +40,5 @@ await insertStuff();
    1. Shell Docs: https://docs.mongodb.com/mongodb-shell/connect/#std-label-mdb-shell-connect

    <sup id="f1">1</sup>Linux instructions [here](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/). [](#1)

    <sup id="f2">2</sup>By default, this will run on `localhost:27017`. [](#2)
  9. danny-andrews revised this gist Jul 14, 2021. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions mongodb-quickstart.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,10 @@

    ## Introduction

    ![ds](https://beginnersbook.com/wp-content/uploads/2017/09/RDBMS_MongoDB_Mapping.jpg)
    1. Read: https://docs.mongodb.com/manual/introduction/
    2. Read: https://docs.mongodb.com/manual/crud/

    ![](https://beginnersbook.com/wp-content/uploads/2017/09/RDBMS_MongoDB_Mapping.jpg)

    ## Installation

    @@ -33,8 +36,6 @@ await insertStuff();
    ## References

    1. Bulk writes: https://docs.mongodb.com/manual/core/bulk-write-operations/
    1. Intro to CRUD operations: https://docs.mongodb.com/manual/crud/
    1. Introduction to MongoDB: https://docs.mongodb.com/manual/introduction/
    1. API Docs: https://mongodb.github.io/node-mongodb-native/4.0/
    1. Shell Docs: https://docs.mongodb.com/mongodb-shell/connect/#std-label-mdb-shell-connect

  10. danny-andrews revised this gist Jul 14, 2021. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion mongodb-quickstart.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,9 @@
    # MongoDB Quickstart
    ![](https://beginnersbook.com/wp-content/uploads/2017/09/RDBMS_MongoDB_Mapping.jpg)

    ## Introduction

    ![ds](https://beginnersbook.com/wp-content/uploads/2017/09/RDBMS_MongoDB_Mapping.jpg)

    ## Installation

    1. `$ brew install mongodb-community` - Installs mongodb server on your machine.<sup id="1">[1](#f1)</sup>
  11. danny-andrews revised this gist Jul 14, 2021. 1 changed file with 1 addition and 7 deletions.
    8 changes: 1 addition & 7 deletions mongodb-quickstart.md
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,11 @@
    # MongoDB Quickstart
    ![](https://beginnersbook.com/wp-content/uploads/2017/09/RDBMS_MongoDB_Mapping.jpg)
    ## Installation

    1. `$ brew install mongodb-community` - Installs mongodb server on your machine.<sup id="1">[1](#f1)</sup>
    2. `$ brew services start mongodb-community` - Starts mongodb server locally.<sup id="2">[2](#f2)</sup>
    3. `$ npm install mongodb` - Installs mongodb node package.

    ## Introduction

    Introduction to MongoDB: https://docs.mongodb.com/manual/introduction/
    Intro to CRUD operations: https://docs.mongodb.com/manual/crud/

    [](https://beginnersbook.com/wp-content/uploads/2017/09/RDBMS_MongoDB_Mapping.jpg)

    ## Usage

    db/mongo-config.js:
  12. danny-andrews created this gist Jul 14, 2021.
    44 changes: 44 additions & 0 deletions mongodb-quickstart.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    # MongoDB Quickstart
    ## Installation

    1. `$ brew install mongodb-community` - Installs mongodb server on your machine.<sup id="1">[1](#f1)</sup>
    2. `$ brew services start mongodb-community` - Starts mongodb server locally.<sup id="2">[2](#f2)</sup>
    3. `$ npm install mongodb` - Installs mongodb node package.

    ## Introduction

    Introduction to MongoDB: https://docs.mongodb.com/manual/introduction/
    Intro to CRUD operations: https://docs.mongodb.com/manual/crud/

    [](https://beginnersbook.com/wp-content/uploads/2017/09/RDBMS_MongoDB_Mapping.jpg)

    ## Usage

    db/mongo-config.js:
    ```js
    import { MongoClient } from "mongodb";

    const URI = "mongodb://localhost:27017/";

    const insertStuff = async () => {
    const client = await new MongoClient(URI).connect();
    const db = client.db("fec");
    const collection = db.collection("items");
    await collection.insertOne({ name: "stuff" });
    await client.close();
    };

    await insertStuff();

    ```

    ## References

    1. Bulk writes: https://docs.mongodb.com/manual/core/bulk-write-operations/
    1. Intro to CRUD operations: https://docs.mongodb.com/manual/crud/
    1. Introduction to MongoDB: https://docs.mongodb.com/manual/introduction/
    1. API Docs: https://mongodb.github.io/node-mongodb-native/4.0/
    1. Shell Docs: https://docs.mongodb.com/mongodb-shell/connect/#std-label-mdb-shell-connect

    <sup id="f1">1</sup>Linux instructions [here](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/). [](#1)
    <sup id="f2">2</sup>By default, this will run on `localhost:27017`. [](#2)