Need suggestion in creating custom product schema

Hello @Nauman_Arshad, welcome to the MongoDB community forum!

You can try this approach, and it has the same details with some structural differences. I have used the wig’s attributes as an array. You can include other properties for different wigs as needed:

product: {
  title: "Wig A",
  description: "Wig A's description",
  attributes: [
    { 
        name: "Stretched Length", 
        details: [ 
            { value: "14 inches", quantity: 10 }, 
            { value: "16 inches", quantity: 6 }, 
            // ... 
        ]
    },
    { 
        name: "Density", 
        details: [ 
            { value: "200 density", quantity: 8 },
            // ... 
        ]
    },
    //
    // ... other attributes, like HairColor, etc.
  ],
  shipFrom: [
    { location: "abc", available: true },
    // ... other locations
  ],
  price: 
  quantity:
  //... other properties
}
1 Like