• Bootcamp (9)
    • 📱 236 - 992 - 3846

      📧 jxjwilliam@gmail.com

    • Version: ‍🚀 1.1.0
  • Mongo

    BootcampBackend2021-02-16


    MongoDB

    • use JSON.parse(json_file) to convert JSON file to JS Object.
    • Use db.collection.insertOne() to insert a single document.
    • db.collection.insertOne, createIndex,

    MongoDB is an open-source document database.

    • High Performance
    • Rich Query Language
    • High Availability
    • Horizontal Scalability
    • Support for Multiple Storage Engines

    Mongoose

    Mongoose is a JavaScript library that allows you to define schemas with strongly typed data. Once a schema is defined, Mongoose lets you create a Model based on a specific schema. A Mongoose Model is then mapped to a MongoDB Document via the Model’s schema definition.

    Mongoose is an Object Document Mapper (ODM). This means that Mongoose allows you to define objects with a strongly-typed schema that is mapped to a MongoDB document.

    Mongoose provides an incredible amount of functionality around creating and working with schemas. Mongoose currently contains eight SchemaTypes that a property is saved as when it is persisted to MongoDB. They are:

    • String
    • Number
    • Date
    • Buffer
    • Boolean
    • Mixed
    • ObjectId
    • Array

    Each data type allows you to specify:

    • a default value
    • a custom validation function
    • indicate a field is required
    • a get function that allows you to manipulate the data before it is returned as an object
    • a set function that allows you to manipulate the data before it is saved to the database
    • create indexes to allow data to be fetched faster

    The ObjectId data type commonly specifies a link to another document in your database. For example, if you had a collection of books and authors, the book document might contain an ObjectId property that refers to the specific author of the document. _id is the common syntax for creating a primary key in Mongoose and MongoDB. We can use the populate() method to pull in the associated information when needed.

    More

    • mongo-express

      $ npm install -g mongo-express
    • docker mongod, local mongod, mongo-express, robomongo ?