Page 1 of 1

Create a row with a pointer to a user

Posted: Thu Aug 08, 2013 2:13 am
by Mike Cardosa

Hello,

I have a collection called categories that has two non-default columns: category_name and user_id. In my app, I'd like to let users create categories that only they can see. I have login working and I am storing both the sessionToken and userID in local variables. When I try to create a new row from the app, I get this error:

"Pointer column value of field 'user_id' must be JSON object but has 'class java.lang.String'"

How am I supposed to pass the userID back to the service? Once it is set, I would be able to build the queries based on the logged in user.

Thanks

Image


Create a row with a pointer to a user

Posted: Thu Aug 08, 2013 5:59 am
by Anton Artyukh5836028

Hi Mike,

Try for user_id param:
precode{ "collName": "user", "id": "51efd..." }/code/pre

More details you can find here.


Create a row with a pointer to a user

Posted: Thu Aug 08, 2013 3:37 pm
by Mike Cardosa

Thanks. That works when I test. Now how do I actually get the form to use that format when it is submitted?

Image


Create a row with a pointer to a user

Posted: Thu Aug 08, 2013 4:04 pm
by Mike Cardosa

I figured it out. I added the following JS to the user_id variable in the request:

var userID = localStorage.getItem('userID');
var user_json = {
"collName" : "user",
"id" : userID
};
return user_json;