Re: Issue in updating the fields inside a sub object in a document

14 views
Skip to first unread message

Sam Helman

unread,
Sep 27, 2012, 11:43:42 AM9/27/12
to mongod...@googlegroups.com
That's not the proper syntax for an "$inc" modifier - the dot notation version you are using is the correct way to use the modifier for nested documents.  The error is occurring because you are passing an invalid update document.

On Thursday, September 27, 2012 6:18:19 AM UTC-4, Yogesh B wrote:
I am trying to update a field named totalTime of subobject named livePerfMeasure . I used the query as below

db.BasicVariable.runCommand("findandmodify", {"query" : { "_id" : "test_test_test_4.4.x_/api/campaingmngmt/campaign/getById" }, "update" : { "$set" : { "dateTime" : ISODate("2012-09-27T06:01:04.000Z")} , "$inc" : { "lifetimeCounterValue" : 1}, "livePerfMeasure" : { "$inc" : { "totalTime" : 300}} }})

But I get the following error

"errmsg" : "exception: assertion src/mongo/db/ops/update_internal.h:253",
 "code" : 0,
 "ok" : 0

Only if I use the dot notation for the key attribute like "$inc" : { "livePerfMeasure.totalTime" : 300}, my query works. So is there any problem with the above query ? Pls help

Reply all
Reply to author
Forward
0 new messages