How can retrieve the data from users table?

We are trying to retrieve data from
backendless user table using the below query as described in
backendless docs. When we run this code we get the error “No visible @interface for messegingsevice’ declares the selector ‘describeUserClass:’” on line [backendless.messagingService describeUserClass:responder];

-(void)retrieveUserEntityProperties

{

Responder *responder = [Responder responder:self

selResponseHandler:@selector(responseHandler1:)

selErrorHandler:@selector(errorHandler:)];

 [backendless.messagingService

describeUserClass:responder];

}

-(id)responseHandler1:(id)response;

{

NSArray *properties = (NSArray *)response;

// NSLog(@"properties = %@, properties);

      return properties;

      }

To retrieve the data from Users table you should use the methods of PersistentService:

-(void)fetchingUsersSync {

@try {

    

    id <IDataStore> dataStore = [backendless.persistenceService of:[BackendlessUser class]];

    BackendlessCollection *users = [dataStore find];

    

    NSLog(@"Users have been fetched (SYNC): %@", users);

}



@catch (Fault *fault) {

    NSLog(@"Server reported an error (SYNC): %@", fault);

}

}

-(void)fetchingUsersAsync {

id <IDataStore> dataStore = [backendless.persistenceService of:[BackendlessUser class]];

[dataStore

 find:^(BackendlessCollection *users) {

     NSLog(@"Users have been fetched (ASYNC): %@", users);

 }

 error:^(Fault *fault) {

     NSLog(@"Server reported an error (ASYNC): %@", fault);

 }];

}

See also the issue on Backendless Blog:
https://backendless.com/feature-52-fetching-applications-user-objects/

This query will give the details of all users in users table. We need only the details of current users not all the users. How can we do this for the current users? After get the data, how can we retrieve details on the basis of properties?

This query will give the details of all users in users table. We need only the details of current users not all the users. How can we do this for the current users? After get the data, how can we retrieve details on the basis of properties?

Could you please define “current”?

Sorry! I meant the user who is logged in i.e. backendless.userService.currentUser

Why can’t you use “backendless.userService.currentUser” ? What is the reason for making a database request?

Regardless of the answer, you should be able to load a user object if you use the following “where clause”:

objectId=“XXXX-XXXX”-XXXX""

Make sure to use specific objectId.

Regards,
Mark

Reason for making database request:

We have added a column in users table which contain the objects of another table based on one to many relation. So we need to fetch the details of this column based on particular user.

Even we get the details from users table based on logged in user using below code. When we print the BackendlessCollection object(users) in NSlog then we can see the information, but not able to retrieve the values of this object.

@try {

    BackendlessCollection *users = backendless.userService.currentUser;
    NSArray *properties = users;


    NSLog(@"Users have been fetched (SYNC): %@", users);
}

@catch (Fault *fault) {
    
    NSLog(@"Server reported an error (SYNC): %@", fault);
    
}

}

One of these articles will help you:

https://backendless.com/feature-28-loading-related-data-objects-the-semi-lazy-approach/
https://backendless.com/feature-22-loading-related-data-objects-the-one-stepdynamic-approach/
https://backendless.com/feature-21-loading-related-data-objects-the-auto-load-approach/

The links you mentioned, all shows the retrieving of data from another table ‘Restaurant’ not from the ‘Users’ table. When we try to create the NSObject class with name as ‘Users’, then XCODE not allowed to create this class as it is being used in backendless SDK. When we remove the backendless SDK, then we able to create the NSObject class with name ‘Users’.

If we are not able to create the class with name ‘Users’, how can we retrieve the records from Users table?

Do not create class Users, instead use this class:

Regards,
Mark

Client SDK BackendlessUser class is mapping to server Users table, so if you need to work with Users table using PersistenceService you should use BackendlessUser class

Thanks Mark! This works, we appreciate your help in this.

could u plz tell me how to retrieve all the data from system table users in android

https://backendless.com/feature-52-fetching-applications-user-objects/

thank you so much
plz give me idea how to update the data
when i am trying to update some data then duplicate data is created

Can you post some sample code that shows how you’re updating data?

its ok dude i got it how to update
right now i m trying to find out data bu using name
here is my code

QueryOptions queryOptions = new QueryOptions();
String whereClause = “userName = '” + name + “’”;
if (!name.equals("")) {
BackendlessDataQuery dataQuery = new BackendlessDataQuery(whereClause);
dataQuery.setQueryOptions(queryOptions);
Backendless.Data.of(BackendlessUser.class).find(dataQuery, new AsyncCallback<BackendlessCollection<BackendlessUser>>() {
@Override
public void handleResponse(BackendlessCollection<BackendlessUser> response) {
BackendlessUser first = response.getCurrentPage().get(0);
String name = (String) first.getProperty(“name”);
GeoPoint geoPoint = (GeoPoint) first.getProperty(“location”);
lat = geoPoint.getLatitude();
longg = geoPoint.getLongitude();
Log.e(“position”, “” + name + lat + longg);
if (lat != null && longg != null) {
showMap();
}
}

@Override
public void handleFault(BackendlessFault fault) {
}
});

but i m not getting anything from this code

I am not getting anything from looking at your code either. Debugger is your best friend now.

What i am trying to do first time user will login with his credentials therefore we can get current user but when we close the app and launch again then user session expires and i am not able to get current user so could u plz suggest me the solution. so that i can update users data.

thanks in advance