Page 1 of 1

how to pass where condition while executing update service from javascript

Posted: Thu Nov 06, 2014 3:58 pm
by Ashish

how to pass where condition while executing update service from javascript

i have a database collection update service and i am executing it from javascript as below

myupdateservice.execute({
data:{
"col1":"data",
"where":{"_id":"id of row which want to update"}
}
});

but getting bed request as response and response message is "Object must be present in the request body"

I have col1 in body tab of request of service and _id in querystring tab.

I am able to update the col value while executing test for this service by providing id value


how to pass where condition while executing update service from javascript

Posted: Thu Nov 06, 2014 4:53 pm
by Maryna Brodina

Hello!

Please check this doc http://devcenter.appery.io/documentat...


how to pass where condition while executing update service from javascript

Posted: Thu Nov 06, 2014 5:26 pm
by Ashish

This is the old documentation.
can you provide me some code snippet regarding executing update service through javascript


how to pass where condition while executing update service from javascript

Posted: Thu Nov 06, 2014 5:31 pm
by Ashish

My problem is that i know how to pass data to service but dont know how to pass querystring


how to pass where condition while executing update service from javascript

Posted: Fri Nov 07, 2014 4:21 am
by Yurii Orishchuk

Hi Ashish,

Here is code below, how to invoke update service "where" and "set" parameters:

pre

updateOptionsService.execute({body: {where: {_id: "53eaa0fce4b0caec8ad032dd"}, operations: {$set: {name: "aloha"} } } })

/pre

Regards.


how to pass where condition while executing update service from javascript

Posted: Fri Nov 07, 2014 3:54 pm
by Ashish

tried this but not working for me it is not returning any error neither getting any success in update in database.


how to pass where condition while executing update service from javascript

Posted: Mon Nov 10, 2014 12:31 am
by Yurii Orishchuk

Hi Ashish,

That's ok.. When "operations" used - returns - empty response with 204 status.

Please check affected rows in your DB collection.

Regards.


how to pass where condition while executing update service from javascript

Posted: Mon Nov 10, 2014 1:56 pm
by Ashish

it is not updating rows in DB collection


how to pass where condition while executing update service from javascript

Posted: Tue Nov 11, 2014 3:09 am
by Yurii Orishchuk

Hi Ashish,

Did you change "where" parameter in accordance to your needs?

If no you have here condtion {where: {_id: "53eaa0fce4b0caec8ad032dd"} it means only item with id "53eaa0fce4b0caec8ad032dd" will be affected.

To clear all conditions you can use following code:

pre

updateOptionsService.execute({body: {where: {}, operations: {$set: {name: "aloha"} } } })

/pre

This code will affect all items in your collection.

Regards.