Jessi
Posts: 0
Joined: Fri Apr 24, 2015 5:38 am

Desperate help

Hi guys, i'm having a problem with the _id in the database. I have 1 collection named userinfo where i store the email and username there. And i also have the standard Users table. But my problem is, for the Users table, _id, it doesn't match my userinfo collection, _id. I want to link my username from Users to userinfo. So how do i do this?? Image Image

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Desperate help

One way to handle this:

  1. Upon creation of user row ... For new user ... Save the _id to a local storage variable.

  2. Add a column to your user info collection called 'userkey' .. String.

  3. When adding a user to your user info table ... In the before execution of the service to do this work... Map the localstorage variable to userkey.

    When you query the user info table ... To get the user info record that matches the logged in user .... Use the query service to do so, and create a where clause mapping the localstorage variable that was created in step 1 above or read during the login event ...to the where clause for the query service.

    Of note ... Another approach is to avoid creating a separate table for user info at all, add the columns to the user table, and , create a read service for the user table .. that pulls back your additional columns..... ( that executes right after the login event ) as well as a service to update that table with the new columns. That's one that I prefer.... But it does involve a little additional weight lifting :-) ..and some weight training.

    Best,
    Bruce

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Desperate help

Hello Jessi,

There are two variantes of solving the issue:
1) (recomended) Use only one collection - Users and write all user's information in this collection https://devcenter.appery.io/documenta...

2) Add column to collection "userinfo" with type=pointer that is related with "Users" collection
https://devcenter.appery.io/documenta...

Return to “Issues”