Joe Bohen
Posts: 0
Joined: Wed Nov 28, 2012 11:28 am

Querying Devices

Hi, How do you query Devices from server script, the collection type with a App-ID rather than a database ID?

curl -X GET \
-H "Content-Type: application/json" \
-H "X-Appery-App-Id: c8e07429-c150-47788182-19937q8-90" \
https://api.appery.io/rest/push/reg/

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Querying Devices

Hi Joe -

The devices are stored in the predefined collection in the database, so I think query just with header app ID won't work in this case.

Joe Bohen
Posts: 0
Joined: Wed Nov 28, 2012 11:28 am

Querying Devices

Thanks for the reply but what is the method used to get the data from the pre-defined collection?

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

Querying Devices

Hi Joe,

Here is JS code for server code to get devices from built-in Devices collection.

precode

var DB_id = "52fd3d06xxxx11c89917&quot

var collectionName = "_devices&quot

try {
result = {};

//Using master key
var token = "2ff60f38-e6ac-4xxxxxxx9-a0c6-2f8282eac042&quot

var params = {};
params.criteria = {};

//Define other parameters
//params.skip = 3; //Skip first 3 records.
//params.limit = 6; //Show maximum 6 records
//params.sort = "studentId&quot //Ascending sort by field "studentId"
result.query = Collection.query(DB_id, collectionName, params, token); //Make the query and save it to the result object

response.success(result);
} catch (e) {
response.success("message: " + e.message + "ncode: " + e.code);
}

/code/pre

Also: don't forget to change settings(DBID and maseter key) with yours.

Regards.

Joe Bohen
Posts: 0
Joined: Wed Nov 28, 2012 11:28 am

Querying Devices

Hi Yurii, Thanks very much for the code it works perfectly.

Return to “Issues”