0
'daki bir dizinin birden çok öğesini nasıl güncelleyebilirim complaints._id
benim şikayet dizisi nesne öğelerini güncellemem gerekiyor. Eğer kimliğe göre arama olmaz çünkü,Mongodb, node js
{
"_id": "570785f0752eab040f347a70",
"createdAt": "2016-04-08T10:20:32.606Z",
"updatedAt": "2016-04-08T10:20:32.606Z",
"bookingid": "5704bd7cbd881ba413274c06",
"specialInstruction": "no special instruction",
"complaints": [
{
"complaint": "head light is not working",
"_id": "570785f0752eab040f347a72",
"labour": 0,
"partCost": 0,
"part": [],
"acceptance": false,
"inspection": false,
"color": "#CE002D",
"status": "WAITING",
"estimate": 0,
"solution": "",
"problems": ""
},
{
"complaint": "clutch is not good condition",
"_id": "570785f0752eab040f347a71",
"labour": 0,
"partCost": 0,
"part": [],
"acceptance": false,
"inspection": false,
"color": "#CE002D",
"status": "WAITING",
"estimate": 0,
"solution": "",
"problems": ""
}
],
"__v": 0
}
Ben bu yaklaşımı çalışıyorum ama findByIdAndUpdate
Basit update
API kullanmak önermek için sorun için
funcs.updatecomplaints=function(request, reply){
var id=request.params.complaintid;
console.log('TESTING'+id);
CPS.findByIdAndUpdate(request.params.documentid, {complaints:{
$set: { status: "WAITING", color : "#CE002D",$where: _id=id}}},
{upsert:true}, function (err, booking) {
Booking.findById(id, function(err, newbooking){
if(err){
console.log('Errorrrr Occured'+JSON.stringify(err));
return reply(JSON.stringify(err)).code(500);
}else{
console.log('All Booking are---->>'+booking);
return reply(newbooking).code(200);
}
});
});
Thanks.Mr Alexandru Olaru iyi çalışıyor çok teşekkürler –