Up until now, we have seen how to interact with MongoDB and perform CRUD operations for our REST API. Here, we are going to define a real-world JSON document that can be implemented by MongoDB. Let us lay down the design of JSON for an e-commerce problem. These five components are a must for any e-commerce design:
- Product
- Customer/user
- Category
- Order
- Review
Let us see a schema of each and every component:
Product:
{ _id: ObjectId("59603d3b0f41ead96110cf4f"), sku: 1022, slug: "highlander-shirt-223", name: "Highlander casual shirt", description: "A nice looking casual shirt for men", details: { model_number: 235476, manufacturer: "HighLander", color: "light blue", mfg_date: new Date(2017, 4, 8), size: 40 }, reviews: 3, pricing: { cost: 23, retail: 29 }, categories: { ObjectId("3d3b10f41efad96g110vcf4f"), ObjectId("603d3eb0ft41ead96110cf4f") }, tags...