Mongoose variable key name

后端 未结 4 1901
眼角桃花
眼角桃花 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:23

    You may try with Schema Type Mixed like this way

    var user = new Schema({
       info:    [Schema.Types.Mixed]
     });
    
    user.info = { any: { thing: 'i want' } };
    user.markModified('info');
    

    You can read more about it here

提交回复
热议问题