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

Server Script Query

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);

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

Server Script Query

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);

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Server Script Query

Hello Joe,

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

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

Server Script Query

Thank you Evgene the code will be very useful.

Return to “Issues”