How to select document by id with Sails-mongo?

后端 未结 3 861
谎友^
谎友^ 2021-01-22 22:09
User.find({ _id: { \'!\': user.id } }, function foundFriends (err, friends) {
    if(err) return next(err);
        res.view({
            friends: friends
        });
}         


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-01-22 22:17

    You can try this:

    User.findOne({ _id : ObjectId(user.id.toString()) })
    

    Hope this help.

提交回复
热议问题