Node.js 如何使用mongoose为给定的输出生成模式?

Node.js 如何使用mongoose为给定的输出生成模式?,node.js,mongodb,mongoose,Node.js,Mongodb,Mongoose,我想像这样存储数据,但我已经做了模式,但我不认为我已经做了正确的方式,请一些人建议我做这件事 { "_id": { "$oid": "5705f793e4b0acd6e2456804a" }, "Categories": [ { "mainmodels": [ { "subm

我想像这样存储数据,但我已经做了模式,但我不认为我已经做了正确的方式,请一些人建议我做这件事

    {
        "_id": {
            "$oid": "5705f793e4b0acd6e2456804a"
        },
        "Categories": [
            {
                "mainmodels": [
                    {
                        "submodels": [
                            {
                                "price": "2000",
                                "submodelname": "lumia021",
                                "Remainingphones": "0",
                                "Bookedphones": "0",
                                "Numofphones": "10"
                            },
{
                            "price": "3000",
                            "submodelname": "lumia21",
                            "Remainingphones": "0",
                            "Bookedphones": "0",
                            "Numofphones": "20"
                        }


                        ],
                        "Status": "Active",
                        "modelname": "lumia",
                        "fromdate": "2016-04-01T16:39:12.051Z",
                        "todate": "2016-04-31T19:19:44.051Z"
                    }
                ],
                "brand": "nokia"
            }
        ],
        "rank": "1",
        "name": "kalasipalaya"
    }
架构设计:

'use strict';

var mongoose = require('mongoose'),
Schema = mongoose.Schema;

var submodelSchema = {

   submodelname: {type:String, required: false},
   price: {type:String, required: false},
   Remainingphones: {type:String, required: false},
   Bookedphones: {type:String, required: false},
   Numofphones: {type:String, required: false}

 };

submodelSchema  = 'new Schema('+ submodelSchema +',{_id:true})';

var typeSchema = {

   brand: {type:String, required: false},
   mainmodels: {
   Status: {type:String, required: false},
   modelname: {type:String, required: false},
   fromdate: {type:String, required: false},
   todate: {type:String, required: false}

   },
   subservices: [submodelSchema], default:[]
};
typeSchema  = 'new Schema('+typeSchema +',{_id:true})';
var PhoneSchema = new Schema({

                rank: {
                        type: String,
                        default: '',
                        trim: true
                },
                name: {
                        type: String,
                        default: '',
                        trim: true
        },
   Categories: [typeSchema], default:[]


});
mongoose.model('Phone', PhoneSchema);

我已经添加了我的模式设计。这个设计正确吗?有人帮我解决bcoz当我更新特定字段时,它没有更新

帮我解决先生@DineshawsLook查看您的代码。为什么
submodelSchema
typeSchema
是字符串?我已经更新了我的子模型中的数据,先生。检查它们仍然是字符串:
submodelSchema='newschema('+submodelSchema+',{id:true}')我怎样才能使“帮助我”先生在上面我已经添加了我的输出