Backendless Support
 
Answered

How to retrieve users with a query

What is the API to retrieve a collection of users with a "where" query?

Leave a Comment

Comments (1)

photo
2

User objects can be retrieved with a search query using the same API as with any other persisted object:

  1. BackendlessDataQuery query = new BackendlessDataQuery( "email LIKE '%@backendless.com'" );
  2. BackendlessCollection<BackendlessUser> friends = Backendless.Data.of( BackendlessUser.class ).find( query );
  3. // once the collection is retrieved, it can be linked to the currently logged in user as shown below
  4. BackendlessUser user = Backendless.UserService.CurrentUser();
  5. user.setProperty( "friends", friends.getCurrentPage() );
  6. Backendless.UserService.update( user );