$addToset do not work in update if record not exists 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 a record exists and a new article id comes it will be added to the set and count will be updated but if the record does not exists then it should store a record. But it gives me an error that while storage $addtoSet and $each are not valid modifier.
I resolved the issue. I made an error in the update statement. The correct version is:

db.TestColl.update({
    "tags" : "silk" ,
    "host" : "host.com"
  }, {
    "$set" : { "cat" : "MOVIE", "publishTime" : 1370427540000 },
    "$addToSet" : {
      "articleId" : { "$each" : [ "20442242" ]}} ,
      "$inc" : { "count" : 1}
  },
  true, false)