How can i design Schema for below product using mongoose?

后端 未结 3 1920
我在风中等你
我在风中等你 2021-01-28 21:15
name: aaaa shirts
category: shirts
subcategory: [{
        type: slimline,
        model: [{
                \"type\": \"twill\",
                \"colour\": [{
                 


        
3条回答
  •  孤独总比滥情好
    2021-01-28 21:29

    //Schema definition Example

    var ProductSchema = new mongoose.Schema({
        name:String,
        category:String,
        subcategory:[{
            type:String,
            model:[{
                type:String,
                colour:[{
                    name:String,
                    image:String
                }],
                size:[{
                    val:Number,
                    price:Number
                }]
            }]
        }],
        description:String,
        created_at:{ type: Date },
        updated_at:{ type: Date, default: Date.now },
        updated:{type: Date, default: Date.now}
    }, { versionKey: false },{strict: false});
    
    export default mongoose.model('Product', ProductSchema);
    

提交回复
热议问题