0
node.jsのmongooseのfindOneでforループを使用するにはどうすれば同じことができるか他のロジックがあるかもしれませんか?Node.JS Mongoose findOne With Loop
data = { _id: '598b4e9abe74280be0b0cb1b' }
{ _id: '598b4ec1be74280be0b0cb1c' }
{ _id: '598b4fa8be74280be0b0cb1d' }
{ _id: '5992feccdad6db0c603b260d' }
{ _id: '5995e4ce0b38ba123cf06654' };
notification = new Array();
for (var i = 0; i < data.length; i++) {
Message.findOne({ from: data[i]._id, to:socket.handshake.session.passport.user }, function(err, message){
if (err){
console.log('error');
}
if(!message.length){
console.log('no message!!');
}else{
notification.push(message);
}
});
}
可能な複製(HTTPS:/ /stackoverflow.com/questions/8303900/mongodb-mongoose-findmany-find-all-documents-with-ids-listed-in-array) – dnickless