Accessing other user's entity

Hello,

I am storing profile information to users table. (Profile information consists of birthday, gender, profile image filename, etc.)

When I query for a user, I never get custom properties, instead I always get 6 key value pairs like the following. It’s not even retrieving lastLogin, how do I retrieve all fields?

email = “<null>”;

name = tom;

objectId = "XXXXXX-XXXX-XXXX-XXXX-XXXXX";

password = "&lt;null&gt;";

userId = "&lt;null&gt;";

userToken = "&lt;null&gt;";

I was hoping to retrieve other user’s information by objectId like the followings.

[[backendless.persistenceService of:[BackendlessUser class]] findID:@“XXXXXX-XXXX-XXXX-XXXX-XXXXX”];

Above code crashes - I guess it’s only for data? (not for users’ table)

Do I have to stick with the below code? Is there’s better way for this?
BackendlessDataQuery *query = [BackendlessDataQuery query];

query.whereClause = [NSString stringWithFormat:@“objectId = ‘%@’”,@“XXXX-XXX”];

[[backendless.persistenceService of:[Users class]] find:query response:^(BackendlessCollection *responseBlock) {

Thanks in advance
Scott

Hi Scott.

  1. Please, add query which you use to receive this data.
  2. You should use Backendless DataQuery to get access to Users table.

Regards,
Kate.

Hi Kate,

Thanks for quick reply. I am new to Backless, please understand if my question is too basic - it’s quiet different from Baas I used previously.

  1. I understand what you mean, but it still does not work on iOS, but it works on Rest console.
    Can you provide sample code retrieving lastLogin field of user data?
    The below is the code for requesting user birthday and lastLogin.

BackendlessDataQuery *query = [BackendlessDataQuery query:@[@“birthday”,@“lastLogin”] where:[NSString stringWithFormat:@“objectId = ‘%@’”,objectId] query:nil];
[[backendless.persistenceService of:[BackendlessUser class]] find:query response:^(BackendlessCollection responseBlock)
for(BackendlessUser
user in responseBlock.data) {
NSDictionary *properties = [user getProperties];

            TRACE(@"%@",[properties objectForKey:@"birthday"]); => null

}

Retrieved data does not contain lastLogin and birthday - only contains 6 key/value pair that’s written on my previous question.

Regrads,
Scott

Any updates?

Sorry for this inconvenience.
Our developer will write you how to resolve this problem.

Regards,
Kate.

Please, update your ios SDK: https://github.com/Backendless/ios-SDK

We have changed logic for custom properties.

Note:
currently we can not execute query with lastLogin values in proper way. This column works only like system property.

If you need to save lastLogin values, you could add property (for example, “lastLoginInApp”)
and update its value after user’s successful authorization.

Hi Kate,

As I tested update, I was able to retrieve custom fields, but failed to retrieve lastLogin.

Regards,
Scott