getting schema attributes from Mongoose Model

后端 未结 9 1818
时光说笑
时光说笑 2020-12-01 06:19

I\'m using Mongoose.js to create models with schemas.

I have a list of models (many) and at times I\'d like to get the attributes/keys that make up a particular mo

9条回答
  •  渐次进展
    2020-12-01 06:29

    Just insert the field name you like to get.

    let fieldName = 'birthday'
    console.log(mySchema.schema.paths[fieldName].instance);
    

提交回复
热议问题