Skip to content

Retrieve User Schema

Description

This operation retrieves a list of the properties associated with the user schema.

Method

Non-Blocking API

public void Backendless.UserService.describeUserClass( AsyncCallback<List<UserProperty>> callback );

The UserProperty class is defined as:

public class UserProperty
{
  // The method returns true if the property is marked as 'identity'
  public boolean isIdentity();

  // Returns the name of the property
  public String getName();

  // Returns true if the property is required during user registration
  public boolean isRequired();

  // Returns the data type of the property
  public DateTypeEnum getType();
}

Blocking API

public List<UserProperty> Backendless.UserService.describeUserClass();

where:

Argument                Description
callback an object which receives either a return value or an error from the server. The return value from the server is a collection of the UserProperty objects.  The class of the callback object must implement the AsyncCallback<Void> interface.

Return Value

An array of UserPropertyobjects containing detailed specification of user properties (the columns in the Users table). Each object has the following properties:

[  
  {  
    "name":"emailaddress",   
    "required":true|false,   
    "type":"STRING"|"STRING_ID"|"DATETIME"|"RELATION"|"INT"|"DOUBLE",  
    "relatedTable":tableName,  
    "identity":true|false   
    "customRegex":"STRING" | null  
    "autoLoad":true|false   
    "isPrimaryKey":true|false   
  },  
  {  
    "name":"password",   
    "required":true|false,   
    "type":"STRING"|"STRING_ID"|"DATETIME"|"RELATION"|"INT"|"DOUBLE",  
    "relatedTable":tableName,  
    "identity":true|false   
    "customRegex":"STRING" | null  
    "autoLoad":true|false   
    "isPrimaryKey":true|false   
  }  
]

where

Argument                Description
name Name of the property/column in the Users table.
required Indicates whether the property is required for user registration.
type Property data type.
defaultValue Default value of the property. The value is used if it is not provided during the registration API call.
identity Indicates whether the property is marked as user identity.
relatedTable If type is "RELATION", contains the name of the related table.
customRegex A regular expression assigned to the column as a validator. The validator applies when a new object is saved in the table or an existing one is updated.
autoLoad Applies only to relations. If true, the property is set to auto-load related data for the data retrieval queries.
isPrimaryKey true if the column is or is a part of a primary key.

Example

The example below retrieves a list of the properties associated with the user schema.

Non-Blocking API

// do not forget to call Backendless.initApp when your app initializes
Backendless.UserService.describeUserClass( new AsyncCallback<List<UserProperty>>()
{
 public void handleResponse( List<UserProperty> properties )
  {
    for( UserProperty userProp : properties )
    {
      Log.i( "MYAPP", "Property name - " + userProp.getName();
      Log.i( "MYAPP", "\trequired - " + userProp.isRequired();
      Log.i( "MYAPP", "\tidentity - " + userProp.isIdentity();
      Log.i( "MYAPP", "\tdata type - " + userProp.getType();
    }
  }

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

Blocking API

// do not forget to call Backendless.initApp when your app initializes
List<UserProperty> properties = Backendless.UserService.describeUserClass();

for( UserProperty userProp : properties )
{
  Log.i( "MYAPP", "Property name - " + userProp.getName();
  Log.i( "MYAPP", "\trequired - " + userProp.isRequired();
  Log.i( "MYAPP", "\tidentity - " + userProp.isIdentity();
  Log.i( "MYAPP", "\tdata type - " + userProp.getType();
}