Mongoose variable key name

后端 未结 4 1920
眼角桃花
眼角桃花 2020-12-19 05:07

I have a mongo object and wish to access it via mongoose for my web app. The schema I\'ve defined has an Object storing user ids and a

4条回答
  •  长情又很酷
    2020-12-19 05:21

    You may define objects and arrays in your schema. You may even combine them. For example, this is an array of objects:

    var user = new Schema({
        foo: [ {
            address: {type: String},
            email: {type: String, unique: true}
        }],
        bar: [ "simple", "array" ]
    });
    

提交回复
热议问题