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:

// returns true if the property is marked as 'identity'
public bool IsIdentity { get;  }

// returns the name of the property
public string Name  { get; }

// returns true if the property is required during user registration
public bool IsRequired  { get;  }

// returns the data type of the property
public DateTypeEnum Type  { get;  }

// returns the default value which is assigned to the property
// when it is missing during the user registration operation
public object DefaultValue  { get; }

// returns true if the property/column represents a relation
// and is marked as auto-load
public bool AutoLoad( get; } 

// Returns the validator regular expression, if the 
// property/column has a validator assigned to it.
public string CustomRegex { get; }

// Returns the name of the related table, if the
// property/column represents a relation
public string RelatedTable { get; }

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.

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

using BackendlessAPI;
using BackendlessAPI.Async;
using BackendlessAPI.Property;

AsyncCallback<List<UserProperty>> callback;
callback = new AsyncCallback<List<UserProperty>>(
        props =>
        {
          foreach( UserProperty p in props )
          {
            System.Console.WriteLine( "prop name " + p.Name );
            System.Console.WriteLine( "\tis identity " + p.IsIdentity );
            System.Console.WriteLine( "\tis required " + p.IsRequired );
            System.Console.WriteLine( "\tprop type " + p.Type );
            System.Console.WriteLine( "\tdefault value " + p.DefaultValue );
          }
        },
        fault =>
        {
          System.Console.WriteLine( fault.ToString() );
        } );

Backendless.UserService.DescribeUserClass( callback );

Blocking API

using BackendlessAPI;
using BackendlessAPI.Async;
using BackendlessAPI.Property;

List<UserProperty> properties = Backendless.UserService.DescribeUserClass();

foreach( UserProperty p in properties )
{
  System.Console.WriteLine( "prop name " + p.Name );
  System.Console.WriteLine( "\tis identity " + p.IsIdentity );
  System.Console.WriteLine( "\tis required " + p.IsRequired );
  System.Console.WriteLine( "\tprop type " + p.Type );
  System.Console.WriteLine( "\tdefault value " + p.DefaultValue );
}