Node JS with Mongoose

Node with Mongoose ORM

  • Blog-Images: One-to-Few
  • Blog-Comments: One-to-Many
  • Category-Blogs: One-to-aLot

One to One

One to Many

Many to Many

Mongo DB Relationships

  1. – One Customer has only one client.

  2. – One client belongs to only one Customer.

one to one

  1. Reference Data Models (Normalization)

  2. Embedded Data Models (Denormalization)

     

// Identifier
{
   _id: "12345xyz",
   client: "BKD2019",
   customer: {
          _id: "cus123", // Identifier[customer_id]
          customerName: "bezkoder",
          location: 29,
          country: "IN"
     }
}
  1. Reference Data Models (Normalization)

// client
{
   _id: "12345xyz",
   client: "BKD2019",
   customer_id: "cus123",
}

// Customer
{
   _id: "cus123",  
   name: "bezkoder",
   location: 29,
   country: "male"
}

Questions?

https://github.com/tkssharma/blog

Baseline Repo for Nest and Type ORM

Thank You

Node JS with Mongoose ORM

By Tarun Sharma

Node JS with Mongoose ORM

  • 313