Deki
Posts: 0
Joined: Tue Apr 15, 2014 4:53 pm

How to get user_id pointer value

I have the following code below, however I am not getting any results based on the following query. I have a user_id which is part of the info_collection and is a pointer to the _id column in Users table. I want to pass in the user id in the params.criteria and then get a "weight" for each user id passed in, but the query returns nothing. Not sure where the problem is....

pre
var DB_id = "my_db_id";
var masterKey = "my_master_key";
var timezone = 'America/Antigua';
var collectionName = "info_collection";

try {
result = {};

var params = {};
params.criteria = {
"user_id": "539f537ae4b0d8c87ced0dc7"
};
//Define other parameters
result.query = Collection.query(DB_id, collectionName, params); //Make the query and save it to the result object

//response.success(result, "application/json");
var i, len, weight;
for (i = 0, len = result&#46;query&#46;length; i < len; i++) {
weight = result&#46;query['weight'];
console&#46;log(weight);
}

} catch (e) {
response&#46;success("message: " + e&#46;message + "ncode: " + e&#46;code);
}
/pre

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

How to get user_id pointer value

Hi Deki,

If you use a field of 'pointer' type, use the following queries: http://devcenter.appery.io/documentat...

For your example, use this params.criteria:preparams&#46;criteria = {
'user_id':{"collName":"users", "id":"537e3b78e4b0604382a2a4cb"}
};/pre

Return to “Issues”