Page 1 of 2

Retrieving data from Appery.io databse

Posted: Wed Feb 12, 2014 7:51 am
by Dev Server

Would like a solution specific to this problem.

http://stackoverflow.com/questions/21...


Retrieving data from Appery.io databse

Posted: Wed Feb 12, 2014 9:44 am
by Maryna Brodina

Hello!
1) Use Collection.query instead profile.query and Collection.getCollectionList instead Profile.getCollectionList
2) You pass parameters in request to collection in a wrong way (here is more information http://docs.appery.io/documentation/b... (Database))
3) Do you call default Users collection? You can't call it this way. Here is more information http://docs.appery.io/documentation/b...


Retrieving data from Appery.io databse

Posted: Mon Feb 17, 2014 4:28 am
by Dev Server

How to do I query two collections at once? And then respond with the collection set where the 'id' in the user collection that does not exist in responses collection.


Retrieving data from Appery.io databse

Posted: Mon Feb 17, 2014 2:38 pm
by Kateryna Grynko

Hi,

If you add a request parameter 'include' where you list connected collections separated by commas. Collection is connected if there is a field of type=pointer points to it.


Retrieving data from Appery.io databse

Posted: Tue Feb 18, 2014 5:17 am
by Dev Server

precode

var userId = request.get("userId");
var usercollection = "Users&quot
var responsecollection = "https://api.appery.io/rest/1/db/collections/Responses&quot

try {
var XHRResponse = XHR.send("GET", "https://api.appery.io/rest/1/db/users", {
"headers": {
"X-Appery-Database-Id": "<id>",
"X-Appery-Master-Key": "<key>"
},
"parameters": {

"limit" : '1',
"where": {"user_id": {"$userId" : {"$nin": {"Reponsescollection"}}}}'
&#47;&#47;"where": '{"_id":{ "$ne" : {"userId":{"$in": "Responsecollection" }}}}'
}
});
response&#46;success(XHRResponse&#46;body, "text/plain");

} catch (e) {
response&#46;success("message: " + e&#46;message + " ncode: " + e&#46;code); &#47;&#47;If something goes wrong error message will appear
}

</pre>/code/pre


Retrieving data from Appery.io databse

Posted: Tue Feb 18, 2014 9:45 am
by Dev Server

precode
var userId = request&#46;get("userId");
var users = XHR&#46;send("GET", "https:&#47;&#47;api&#46;appery&#46;io/rest/1/db/users");
var responses = request&#46;get("https:&#47;&#47;api&#46;appery&#46;io/rest/1/db/collections/Responses");

try {

var XHRResponse = XHR&#46;send("GET", "https:&#47;&#47;api&#46;appery&#46;io/rest/1/db/users", {
"headers": {
"X-Appery-Database-Id": "<id>",
"X-Appery-Master-Key": "<key>"
},
"parameters": {
"inlcude" : "responses",
"limit" : '1',
"where": '{"_id":{ "$ne" : {"userId":{"$in": "responses" }}}}'

Code: Select all

 } 

});

response&#46;success(XHRResponse&#46;body, "text/plain");

} catch (e) {
response&#46;success("message: " + e&#46;message + " ncode: " + e&#46;code); &#47;&#47;If something goes wrong error message will appear
}

/code/pre


Retrieving data from Appery.io databse

Posted: Tue Feb 18, 2014 9:48 am
by Dev Server

precode

var userId = request&#46;get("userId");
var responses = request&#46;get("https:&#47;&#47;api&#46;appery&#46;io/rest/1/db/collections/Responses");

try {

var XHRResponse = XHR&#46;send("GET", "https:&#47;&#47;api&#46;appery&#46;io/rest/1/db/users", {
"headers": {
"X-Appery-Database-Id": "<id>",
"X-Appery-Master-Key": "<key>"
},
"parameters": {
"inlcude" : "responses",
"limit" : '1',
"where": '{"_id":{ "$ne" : {"userId":{"$in": "responses" }}}}'

Code: Select all

 } 

});

response&#46;success(XHRResponse&#46;body, "text/plain");

} catch (e) {
response&#46;success("message: " + e&#46;message + " ncode: " + e&#46;code); &#47;&#47;If something goes wrong error message will appear
}

/code/pre


Retrieving data from Appery.io databse

Posted: Tue Feb 18, 2014 8:34 pm
by Maryna Brodina

Hello!
Sorry, not sure I understand what are you trying to do, but looks like you have a few errors in code prevar responses = request&#46;get("https:&#47;&#47;api&#46;appery&#46;io/rest/1/db/collections/Responses");/preWhat do you want to do with this code? What do you want to pass in where? Please debug your code. Use console.log and Trace tab to see what you have in variables, what requests you send.


Retrieving data from Appery.io databse

Posted: Wed Feb 19, 2014 10:27 am
by Dev Server

ok so I've got two collections

Users [id, username, password, dob, gender, ...]
Responses [id, user_id, recipient_id, state, username, recipient_username, .... ]

All I want done is to get view all the users from (Users Collection) that are not in (Responses Collection) based on the the user_id.

Something like this
"SELECT * FROM 'users' NOT IN (SELECT 'user_id' FROM 'Responses' WHERE 'user_id'= + 'logged_user_Id' +)"

I am a neophyte, just trying to get it work

http://docs.appery.io/documentation/b...
http://docs.appery.io/documentation/b...


Retrieving data from Appery.io databse

Posted: Wed Feb 19, 2014 10:36 am
by Ram6675664

hjghj