Page 2 of 4

Using ?WHERE= in URL database call

Posted: Sun Dec 08, 2013 8:24 pm
by Igor

Please try next code:
pre
$.ajax({
type: "GET",
beforeSend: function(request) {
request.setRequestHeader("X-Appery-Database-Id", "5166b6a8e4b055aafd1f2167");
},
url: "https://api.appery.io/rest/1/db/collections/todo",
data: {
where: JSON.stringify({Name:"name2"})
},
dataType: "json",
success: function(response) {
console.log("Successfully loaded");
},
error: function(xhr, ajaxOptions, thrownError) {
console.log("Load error: " + xhr.status + " " + xhr.responseText);
}
});
/pre


Using ?WHERE= in URL database call

Posted: Sun Dec 08, 2013 9:36 pm
by Andrew Walker

This works great as manual, but if "name2" was a variable, it does not show the var value, just another error?


Using ?WHERE= in URL database call

Posted: Sun Dec 08, 2013 9:41 pm
by Igor

Name - it's a Db collection filed name, "name2" - field value. If you use variable in where cause it should be enclosed in single quotes. Something like this:
"'variableName'"


Using ?WHERE= in URL database call

Posted: Sun Dec 08, 2013 10:20 pm
by Andrew Walker

Thank you, works a treat :)


Using ?WHERE= in URL database call

Posted: Tue Jan 28, 2014 4:13 pm
by Bad Addy

Hello, I have some code, and its not working. The Where clause, as above, does not come back with anything. But it will bring back all records without the data: part in.

code
dataType: 'json',
contentType: 'application/json; charset=utf-8',
data: {
where: JSON.stringify({sid:sid})
},
/code

Any ideas ?


Using ?WHERE= in URL database call

Posted: Tue Jan 28, 2014 6:22 pm
by Bad Addy

I cannot seem to fix this. Really need a hand. It seems to work based on the comments, but now its not working, if i copy exactly the same!!


Using ?WHERE= in URL database call

Posted: Tue Jan 28, 2014 6:30 pm
by Kateryna Grynko

Hi,

Please share the app with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a and tell us where to see this


Using ?WHERE= in URL database call

Posted: Tue Jan 28, 2014 7:42 pm
by Bad Addy

This is using REST API not in appery. sid is a number, and is given a number in the database, rather than string. Would that make a difference. ?

I have added support.


Using ?WHERE= in URL database call

Posted: Tue Jan 28, 2014 7:44 pm
by Kateryna Grynko

What is the app name?


Using ?WHERE= in URL database call

Posted: Tue Jan 28, 2014 7:48 pm
by Bad Addy

urVoice