Ich bin neu in Nodejs für Schleife nicht synchron funktioniert. Bitte helfen Vielen Dank im VorausSchleife funktioniert nicht richtig in Knoten js
hier ist mein Code
notifyRide:function*(body){
yield User.find({_id: {$ne: body.userId}},function(err, doc){
if(doc != null){
User.findOne({_id:body.userId},function(err, user){
Ride.findOne({_id : body.rideid},function*(err1,ride){
for (var i = 0; i < doc.length; i++) {
console.log(i)// getting 0
yield rideStatus.findOne({$and:[{receiver_id:doc[i]._id},{ride_id:body.rideid}]}, function(err, response)
{
console.log(i);//getting 1
})
}
})
})
}
})
}
Did [meine Antwort] (https://stackoverflow.com/questions/45170956/loop-not-working- richtig-in-node-js/45171189 # 45171189) unten helfen Ihnen? Irgendwelche Kommentare? – rsp