如何在另一个模式猫鼬中获取一个模式的特定字段的引用?

我有两种不同的模式,我想将一个模式的特定字段(具有其自己的ObjectId)引用到另一种模式。

这是针对具有mongodb,mongoose,nodejs的Web应用程序。

#This is a Schema of Order#

var orderSchema = new Schema({
    deliveryAddress: {
        type: Schema.Types.ObjectId,required: true,ref: "user.address"//This is where I want to give ref of 
                          //another schemas particular Object field
    }
})
module.exports = mongoose.model("order",orderSchema);


##This  is Schema of User##

var userSchema = new Schema({
address: [{
    pincode: {
        type: Number,required: true
    },address: { //This Object fiels Id I want to give ref to 
               //another schema
    type: String,required: true
    }
}] })
      module.exports = mongoose.model("user",userSchema);



After populate of order I should get all details of respective 
address
chen477293 回答:如何在另一个模式猫鼬中获取一个模式的特定字段的引用?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3127806.html

大家都在问