Dev Server
Posts: 0
Joined: Wed Feb 12, 2014 7:51 am

Retrieving data from Appery.io databse

Would like a solution specific to this problem.

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Retrieving data from Appery.io databse

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...

Dev Server
Posts: 0
Joined: Wed Feb 12, 2014 7:51 am

Retrieving data from Appery.io databse

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.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Retrieving data from Appery.io databse

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.

Dev Server
Posts: 0
Joined: Wed Feb 12, 2014 7:51 am

Retrieving data from Appery.io databse

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

Dev Server
Posts: 0
Joined: Wed Feb 12, 2014 7:51 am

Retrieving data from Appery.io databse

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

Dev Server
Posts: 0
Joined: Wed Feb 12, 2014 7:51 am

Retrieving data from Appery.io databse

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Retrieving data from Appery.io databse

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.

Dev Server
Posts: 0
Joined: Wed Feb 12, 2014 7:51 am

Retrieving data from Appery.io databse

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...

Ram6675664
Posts: 0
Joined: Wed Feb 19, 2014 10:36 am

Retrieving data from Appery.io databse

hjghj

Return to “Issues”