我想获取所有文档的特定数据字段的数据

时间:2019-05-20 07:36:07

标签: javascript mongodb mongoose

我想获取nameValue中由该特定模式定义的每个文档的emailValueaddressValuecardnamemongoose的数据。它将生成一个ID,我是否必须遍历该ID并从数据库中获取所有所需的数据字段?

RegisterModelSchema = new Schema({
   cred: {
       nameValue: {
           type: String,
           required: true,
       },
       emailValue: {
           type: String,
           required: true,
       },
       passwordValue: {
           type: String,
           required: true,
       },
   },
   location: {
       addressValue: {
           type: String,
           required: true,
       },
       cityValue: {
           type: String,
           required: true,
       },
       stateValue: {
           type: String,
           required: true,
       },
       postalValue: {
           type: Number,
           required: true,
       },
   },
   card: {
       cardName: {
           type: String,
           required: true,
       },
       cardNumber: {
           type: Number,
           required: true,
       },
       securityCode: {
           type: Number,
           required: true,
       },
       expirationMonth: {
           type: Number,
           required: true,
       },
       expirationYear: {
           type: Number,
           required: true,
       },
   }

0 个答案:

没有答案