Skip to content

Retrieving Schema Definition

Backendless provides API for data table schema introspection. The API returns information about table's columns and their data types, whether a value for a column is required or if there is a default value.

Method:

GET

Endpoint URL

The xxxx.backendless.app is a subdomain assigned to your application. For more information see the Client-side Setup section of this documentation.

https://xxxx.backendless.app/api/data/<table-name>/properties 

where:

Argument                Description
<table-name> Name of the table to retrieve the schema for.

Request Headers

user-token:value-of-the-user-token-header-from-login

where:

Argument                Description
user-token Optional header. Contains a value returned by Backendless in a preceding user Login API call. If user-tokenis set in the request, the operation will be executed with the security policy associated with the currently logged in user. This means all permissions associated with the user and roles assigned to the user will be enforced by Backendless.

Request Body

None

Response Body:

An array of JSON objects each with the following structure:

{  
autoLoad: true or false,  
customRegex: value,  
defaultValue: null or value,  
isPrimaryKey: true or false,  
name: value,  
relatedTable: null or table name,  
required: true or false,  
type: data type  
}

where:

Argument                Description
autoLoad Applies only to relations. If true, the property is set to auto-load related data for the data retrieval queries.
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.
defaultValue A default value assigned to any object saved/updated in the table where the column does not have a value.
isPrimaryKey true if the column is or is a part of a primary key.
name Contains the name of a property.
relatedTable Contains the name of the related table. This is applicable only to relation columns.
required Defines whether a property is optional or required for the requests which save the initial object or update an existing one.
type Defines the column type.

Example

Suppose the Person table has the following schema - there are two developer-defined columns, age and name.

person-schema.zoom50

To retrieve the schema of the Person table using API, run the following request:

curl "http://api.backendless.com/application-id/REST-api-key/data/Person/properties"

The response is an array of JSON objects, each representing a column:

[  
  {  
    "name": "updated",  
    "required": false,  
    "type": "DATETIME",  
    "defaultValue": null,  
    "relatedTable": null,  
    "customRegex": null,  
    "autoLoad": false,  
    "isPrimaryKey": false  
  },  
  {  
    "name": "created",  
    "required": false,  
    "type": "DATETIME",  
    "defaultValue": null,  
    "relatedTable": null,  
    "customRegex": null,  
    "autoLoad": false,  
    "isPrimaryKey": false  
  },  
  {  
    "name": "objectId",  
    "required": false,  
    "type": "STRING_ID",  
    "defaultValue": null,  
    "relatedTable": null,  
    "customRegex": null,  
    "autoLoad": false,  
    "isPrimaryKey": true  
  },  
  {  
    "name": "ownerId",  
    "required": false,  
    "type": "STRING",  
    "defaultValue": null,  
    "relatedTable": null,  
    "customRegex": null,  
    "autoLoad": false,  
    "isPrimaryKey": false  
  },  
  {  
    "name": "name",  
    "required": false,  
    "type": "STRING",  
    "defaultValue": null,  
    "relatedTable": null,  
    "customRegex": null,  
    "autoLoad": false,  
    "isPrimaryKey": false  
  },  
  {  
    "name": "age",  
    "required": false,  
    "type": "INT",  
    "defaultValue": null,  
    "relatedTable": null,  
    "customRegex": null,  
    "autoLoad": false,  
    "isPrimaryKey": false  
  }  
]

Codeless Reference

data_service_get_table_schema

where:

Argument                Description
table name Name of the data table to get the schema definition for.

Returns a list containing JSON objects each with the following structure:

{  
autoLoad: true or false,  
customRegex: value,  
defaultValue: null or value,  
isPrimaryKey: true or false,  
name: value,  
relatedTable: null or table name,  
required: true or false,  
type: data type  
}

where:

Argument                Description
autoLoad Applies only to relations. If true, the property is set to auto-load related data for the data retrieval queries.
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.
defaultValue A default value assigned to any object saved/updated in the table where the column does not have a value.
isPrimaryKey true if the column is or is a part of a primary key.
name Contains the name of a property.
relatedTable Contains the name of the related table. This is applicable only to relation columns.
required Defines whether a property is optional or required for the requests which save the initial object or update an existing one.
type Defines the column type.

The schema of the data table presented below has three custom columns: name, position, and phoneNumber.
data_service_example_get_table_schema_2

The operation below retrieves the schema of the employees data table.

data_service_example_get_table_schema_1

The result of this operation will look as shown below after the Codeless logic runs. As you can see,  the operation returns a list of JSON objects containing detailed information about each column.

data_service_example_get_table_schema_3