猫鼬参考嵌套数组

时间:2020-08-13 02:53:38

标签: node.js mongodb

有两个架构作业和一个用户

const JobSchema: Schema = new Schema(   
   location: {
      type: mongoose.Types.ObjectId,
      ref: '',
      required: true,
      trim: true,
    },
},

const UserSchema: Schema = new Schema(
    email: { type: String, required: true, unique: true, trim: true },
    addresses: [
      {
        address: {
          title: String,
          house: String,
          street: String,
        },
      },
    ],
}

我在位置字段中存储了地址ID, 但模型是userModel, 因此,如何从一个模型填充到另一个模型的嵌套数组ID?

0 个答案:

没有答案