


Learn more MongoDB Shell Interface with MongoDB Use the MongoDB Shell to connect, configure and work with your database. MongoDB Compass Navigate & Explore Your Data The quickest way to connect, visually explore and interact with your data. There is a lot more, you can read the mongoose documentation to find the properties that fits your needs. To create a new collection using MongoDB Compass, connect compass to your server and select the database. Choose from our collection of MongoDB tools so that you can build faster, bigger, and better. There is also the unique property, that means that you can’t create 2 users with the same email or name or any field that you define. The type property defines the type of the field, it can be a Number, String or in this case a MongooseSchema Object Id, we can define if it’s required or not, this means that if it is set to true, you can’t create a for example a Sale without a client.
MONGODB COMPASS PLUGINS CODE
Let’s analyze a bit how it’s done:, required: false, ref: Client.name}) client: any any workflow Packages Host and manage packages Security Find and fix vulnerabilities Codespaces Instant dev environments Copilot Write better code with Code review Manage code changes Issues Plan and track work Discussions Collaborate outside code Explore All. In the Sales we are referencing the product and client. NestJS and mongoose allow you to relate the entities, you can see in the code that for example we are referencing the User Schema on the Sales, Clients and Products to register the user that is creating each event. Here is a little diagram with the schemas that describe the relations between the entities.ġ- So we are going to create a user with a specific roleĤ- Create a Sale for a created Product to a specific Client

So here is the deal, the entities are the key to make this work, so let’s relate them.
