Kal
Posts: 0
Joined: Thu May 22, 2014 11:03 pm

Example code for multiUpdateObject, please?

With reference to: http://devcenter.appery.io/documentat...

Examples are given for a few of the operations, but none for the multiUpdateObject case. This is fairly complex, and I have tried a few different things without success. In particular I would like to see a working example of how the $inc operator can be used increment a numeric field using the multiUpdateObject function.

Or, if you can take the same example here: http://devcenter.appery.io/documentat..., and show how $set is done with the Object API (rather than the XHR way), that would be fine too!

Thanks,
-Kal.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Example code for multiUpdateObject, please?

Hello!

For $set:

preCollection.multiUpdateObject("",
"some_collection",
JSON.stringify({'col_1': '1'}),
null,
{$set: {'col_2':'2'}}
);/pre

For $inc:

preCollection.multiUpdateObject("",
"some_collection",
JSON.stringify({'col_1': '1'}),
null,
{$inc: {'num_col':1}}
);/pre

Kal
Posts: 0
Joined: Thu May 22, 2014 11:03 pm

Example code for multiUpdateObject, please?

Thanks! That worked great. I assume the first "" is place-holder for dbId.

The puzzling thing to me is why the 3rd parameter (query criterion) needs to be stringified, whereas the 5th parameter (operation) does not need to be stringified.

-Kal.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Example code for multiUpdateObject, please?

Hello Kal,

Because 3rd and 5th parameters have to be in different structure. You can read more about multiUpdateObject here http://devcenter.appery.io/documentat...

Kal
Posts: 0
Joined: Thu May 22, 2014 11:03 pm

Example code for multiUpdateObject, please?

Thanks, Evgene. Yes, I already had read the documentation you pointed to to a few times, but I must say it is not very clear!

With Maryna's example I am able to get my work done, so no worries. I would definitely recommend that example be included in the documentation to make it easy for others as well.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Example code for multiUpdateObject, please?

Hello Kal!

Added to docs!

Return to “Issues”