Page 1 of 1

Server Script Query

Posted: Fri Apr 03, 2015 3:07 pm
by Joe Bohen

Hi, I am attempting to return the user ID using server script.

I login the user and obtain the token then I query the collection using the token and the parameter which contains the username held in the collection, the result is the complete collection! How would id do this correctly?

The query:

var object={};
object = DatabaseUser.query(DB_id, { "username" : userName }, token);


Server Script Query

Posted: Fri Apr 03, 2015 9:23 pm
by Joe Bohen

Hi Illia,

Don't know if this is the correct approach but it appears to obtain the information I require (so far) is this correct or is there an easier simpler method?

Regards,
Joe

varr DB_id = "50b33f33yysheytishjvcvdbc;
var userName ="XYZ123";
var userPass ="MIFFED";
var masterKey ="";

try {
result = {};
var token = DatabaseUser.login(DB_id, userName, userPass).sessionToken;

result.token = token;

// console.log(token);
var ID = DatabaseUser.login(DB_id, userName, userPass)._id;

result.id = ID;

console.log(result);


Server Script Query

Posted: Sat Apr 04, 2015 3:30 am
by Evgene Karachevtsev

Hello Joe,

It looks like that this approach is correct. Maybe this post will also be useful for you: https://getsatisfaction.com/apperyio/...


Server Script Query

Posted: Sat Apr 04, 2015 8:21 am
by Joe Bohen

Thank you Evgene the code will be very useful.