mardi 2 décembre 2014

$addToset do not work in update if record not exists


Hi I am trying to use following query db.TestColl.update({ "tags" : "silk" , "host" : "host.com"},{ "$set" : { "cat" : "MOVIE" , "$addToSet" : { "articleId" : { "$each" : [ "20442242"]}} , "publishTime" : 1370427540000} , "$inc" : { "count" : 1}},true,false);


The reason is if record exists and new article id comes it will added to set and count will eb updated but if record does not exists then it should store a record. But it gives me error that while storage $addtoSet and $each are not valid modifier.





Aucun commentaire:

Enregistrer un commentaire