Shamma
Posts: 0
Joined: Thu Mar 12, 2015 4:35 pm

Updating multiple rows in server code

Hello , I'm trying to make a server code that will update a column in my database to a certain value , my code is like this :
var XHRResponse = XHR.send("PUT", "https://api.appery.io/rest/1/db/colle...", {
"headers": {
"X-Appery-Database-Id": "****",
"X-Appery-Master-Key": "****",
"Content-Type": "application/json"
},
"parameters": {
"operations": ' {"$set":{"Available":'+true}}'

Code: Select all

 }

});

I just want to make all the values in the column "Available" to be true , somehow I get syntax error in the trace when I try to run this code , please whats the problem

Regards

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Updating multiple rows in server code

Hello,

Please change
pre"operations": ' {"$set":{"Available":'+true}}'/pre
to this:
pre"operations": {"$set":{"Available":true}}/pre

Shamma
Posts: 0
Joined: Thu Mar 12, 2015 4:35 pm

Updating multiple rows in server code

Hello ,
I changed the code as you mentioned previously and this is how it looks now :
var responseBody = {},
requestParams = {},
paramKeys = Apperyio.request.keys();

for (var key = 0; key < paramKeys.length; key++) {
requestParams[paramKeys[key]] = Apperyio.request.get(paramKeys[key]);
}
responseBody.requestBody = Apperyio.request.body();
responseBody.requestParams = requestParams;

var XHRResponse = XHR.send("PUT", "https://api.appery.io/rest/1/db/colle...", {

Code: Select all

"headers": { 
     "X-Appery-Database-Id": ***************, 
     "X-Appery-Master-Key": ****************, 
     "Content-Type": "application/json" 

   }, 
  "parameters": { 
"operations": {"$set":{"Available":true}} 

 } 

});

console.log(XHRResponse.body);

the error I get in the trace is :
Script resetScheduels: Error: com.mongodb.BasicDBObject cannot be cast to java.lang.String ( @ 43 : 18 ) - throw e;

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Updating multiple rows in server code

Could you use collections API instead of XHR? https://devcenter.appery.io/documenta...

Return to “Issues”