Ashish
Posts: 0
Joined: Sat Sep 13, 2014 3:18 pm

how to pass where condition while executing update service from javascript

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

Ashish
Posts: 0
Joined: Sat Sep 13, 2014 3:18 pm

how to pass where condition while executing update service from javascript

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

Ashish
Posts: 0
Joined: Sat Sep 13, 2014 3:18 pm

how to pass where condition while executing update service from javascript

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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

how to pass where condition while executing update service from javascript

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.

Ashish
Posts: 0
Joined: Sat Sep 13, 2014 3:18 pm

how to pass where condition while executing update service from javascript

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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

how to pass where condition while executing update service from javascript

Hi Ashish,

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

Please check affected rows in your DB collection.

Regards.

Ashish
Posts: 0
Joined: Sat Sep 13, 2014 3:18 pm

how to pass where condition while executing update service from javascript

it is not updating rows in DB collection

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

how to pass where condition while executing update service from javascript

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.

Return to “Issues”