DEV Community

wasim15185
wasim15185

Posted on

how to I to populate mongoose 'totalMsg' inside 'msg' ...........

let userSchema = new mongoose.Schema({
    name: String,
    password: String,
    email: {
        type: String
    },
    username: String,
    friends: [ { type: mongoose.Types.ObjectId } ],
    totalMsg: [
        {
            id: { type: mongoose.Types.ObjectId, ref: 'user' },
            msg: [ { type: mongoose.Types.ObjectId, ref: 'message' } ]
        }
    ]
});
Enter fullscreen mode Exit fullscreen mode

Top comments (0)