Category: MongoDB

  • MongoDB Charts

    MongoDB Charts MongoDB Charts lets you visualize your data in a simple, intuitive way. MongoDB Charts Setup From the MongoDB Atlas dashboard, go to the Charts tab. If you’ve never used Charts before, click the Activate Now button. This will take about 1 minute to complete. You’ll see a new dashboard. Click the dashboard name to open it. Creating a…

  • MongoDB Node.js Database Interaction

    Node.js Database Interaction For this tutorial, we will use a MongoDB Atlas database. If you don’t already have a MongoDB Atlas account, you can create one for free at MongoDB Atlas. We will also use the “sample_mflix” database loaded from our sample data in the Intro to Aggregations section. MongoDB Node.js Driver Installation To use MongoDB with Node.js,…

  • MongoDB Drivers

    MongoDB Drivers The MongoDB Shell (mongosh) is great, but generally you will need to use MongoDB in your application. To do this, MongoDB has many language drivers. The language drivers allow you to interact with your MongoDB database using the methods you’ve learned so far in `mongosh` but directly in your application. These are the…

  • MongoDB Data API

    MongoDB Data API The MongoDB Data API can be used to query and update data in a MongoDB database without the need for language specific drivers. Language drivers should be used when possible, but the MongoDB Data API comes in handy when drivers are not available or drivers are overkill for the application. Read & Write with…

  • MongoDB Schema Validation

    Schema Validation By default MongoDB has a flexible schema. This means that there is no strict schema validation set up initially. Schema validation rules can be created in order to ensure that all documents a collection share a similar structure. Schema Validation MongoDB supports JSON Schema validation. The $jsonSchema operator allows us to define our document structure. Example This…

  • Indexing & Search

    Indexing & Search MongoDB Atlas comes with a full-text search engine that can be used to search for documents in a collection. Atlas Search is powered by Apache Lucene. Creating an Index We’ll use the Atlas dashboard to create an index on the “sample_mflix” database from the sample data that we loaded in the Intro to Aggregations section.…

  • MongoDB Aggregation Pipelines

    Aggregation Pipelines Aggregation operations allow you to group, sort, perform calculations, analyze data, and much more. Aggregation pipelines can have one or more “stages”. The order of these stages are important. Each stage acts upon the results of the previous stage. Example Sample Data To demonstrate the use of stages in a aggregation pipeline, we…

  • MongoDB Update Operators

    MongoDB Update Operators There are many update operators that can be used during document updates. Fields The following operators can be used to update fields: Array The following operators assist with updating arrays.

  • MongoDB Query Operators

    MongoDB Query Operators There are many query operators that can be used to compare and reference document fields. Comparison The following operators can be used in queries to compare values: Logical The following operators can logically compare multiple queries. Evaluation The following operators assist in evaluating documents.

  • MongoDB mongosh Delete

    Delete Documents We can delete documents by using the methods deleteOne() or deleteMany(). These methods accept a query object. The matching documents will be deleted. deleteOne() The deleteOne() method will delete the first document that matches the query provided. Example deleteMany() The deleteMany() method will delete all documents that match the query provided. Example