Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
366 views
in Technique[技术] by (71.8m points)

mongoose 的 pupolate 联表查询

const friendSchema = new mongoose.Schema({
    userID: String,    //用户id
    friend_list: Array,
    group_list: {
        A: [
            { "id": { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, "nickName": String }
        ],
        B: [
            { "id": { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, "nickName": String }
        ],
        C: [
            { "id": { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, "nickName": String }
        ],
        D: [
            { "id": { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, "nickName": String }
        ]
    }
})
module.exports = mongoose.model("friend", friendSchema);

这种数据结构 mongoose 怎么用 populate 联表查询填充id字段


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...