Mongoose,populating字段返回一个空数组

时间:2016-04-11 08:22:53

标签: javascript node.js mongodb mongoose

我知道我notifications的{​​{1}}字段中有对象,但当我在user上调用时,它们正在消失。

填充代码

notifications

用户架构

User.findById(socket.request.user._id).populate('notifications').exec(function(err, user) {
        console.log('get notification populated user', user);
        var unread = user.unread;
        var notifications = user.notifications;
        socket.emit('take notifications', {
            notifications: notifications,
            num_unread: unread
        });
    });

0 个答案:

没有答案