Sorry, I can't find answer and I can't read english.
What's keyword can find answer about the following example code ?
for(var value in row){
db.collection('testdb').update({_id:'id'},{$addToSet:value},
{ upsert: true },function(err){}
)
value.empty();
}
I don't know why my code can't work
testdb: { "_id" : "id", "v" : [v1], "p" : [ p1] }
after repeat update
{ "_id" : "id", "v" : [v1,p2], "p" : [ p1,p2] }
but should be
{ "_id" : "id", "v" : [v1,v2], "p" : [ p1,p2] }
to Neil Lunn
row count = 2 ;
row[0] = { "v" : [v2] }
row[1] = { "p" : [p2] }
to Farid Nouri Neshat
app.post('index',function(req,res){
var doc =[];
var d ={};
var e ={}
for(var value in req.body){
d[value]=doc;
e['$each']=doc;
d[value]=e;
db.collection('testdb').update({_id:req.body.field},{$addToSet:d},
{ upsert: true },function(err){})
doc=[];//clear doc
d={};//clear d
}
}
// req.body.count = 2
// req.body[0] = { "v" : [v2] }
// req.body[1] = { "p" : [p2] }
}