Page 1 of 1

Example code for multiUpdateObject, please?

Posted: Tue Feb 24, 2015 5:46 pm
by Kal

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.


Example code for multiUpdateObject, please?

Posted: Wed Feb 25, 2015 11:30 am
by Maryna Brodina

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


Example code for multiUpdateObject, please?

Posted: Wed Feb 25, 2015 6:00 pm
by Kal

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.


Example code for multiUpdateObject, please?

Posted: Wed Feb 25, 2015 8:53 pm
by Evgene Karachevtsev

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...


Example code for multiUpdateObject, please?

Posted: Thu Feb 26, 2015 4:53 am
by Kal

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.


Example code for multiUpdateObject, please?

Posted: Thu Feb 26, 2015 4:26 pm
by Maryna Brodina

Hello Kal!

Added to docs!