Single Step Retrieval¶
Important
Single Step Retrieval loads only a partial set of the related objects (default size of the retrieved related collection is 10). To load additional related objects, use the Relation Paging API .
This approach allows retrieval of a partial set of the related objects along with the parent object in a single find
or findById
request. Each relationship property (column) must be uniquely identified by name using the API documented below.
Method¶
Backendless.Data.of("TABLE-NAME").findById<T = object>(objectId, queryBuilder?): Promise<T>;
Retrieving a specific object with relations¶
Backendless.Data.of( "TABLE-NAME" ).findById( "XXXX-XXXX-XXXX-XXXX", {
relations:["relationA", "relationB"] })
.then( function( result ) {
})
.catch( function( error ) {
});
Backendless.Data.of( DataTypeX ).findById( {objectId:"XXXX-XXXX-XXXX-XXXX",
loadRelations:"relationA,relationB" })
.then( function( result ) {
})
.catch( function( error ) {
});
Retrieving a collection of objects with relations¶
var queryBuilder = Backendless.DataQueryBuilder.create();
queryBuilder.setRelated( [ "RELATED-PROPERTY-NAME",
"RELATED-PROPERTY-NAME.RELATION-OF-RELATION" ] );
Then load data using the constructed queryBuilder
object with:
Backendless.Data.of( "TABLE-NAME" ).find( queryBuilder )
.then( function( objectCollection ) {
})
.catch( function( error ) {
});
Backendless.Data.of( DataTypeX ).find( queryBuilder )
.then( function( objectCollection ) {
})
.catch( function( error ) {
});
where
Argument | Description |
---|---|
TABLE-NAME |
Name of the table where the data should be retrieved from |
objectId |
 Unique identifier of a record that must be retrieved from the data table. String value or number. Refer to the Data Import topic to learn more about the objectId value as the number. |
queryBuilder |
An instance of the Backendless.DataQueryBuilder class. The class is used to identify related properties for relation retrieval. |
RELATED-PROPERTY-NAME |
Name of a related property to load. For example, if table Person has a relation "homeAddress " pointing to an object in the Address table, the value would be "homeAddress ". The syntax allows to add relations of relations. For example, if the same Address table has a relation "country " pointing to the Country table, then "homeAddress.country " would instruct the related Country object to be loaded as well. |
DataTypeX |
Reference to a class/function which identifies a table where the data should be loaded from. |
Codeless Reference¶
Consider the following structure of the data table called employees
:
As you probably noticed, the skills column has a relation to the uniqueSkills
data table with the following structure:
One-to-many relation stored in the skills
column references the following objects stored in the uniqueSkills
data table:
The example below retrieves all related objects of the parent object
: Notice how the parent object
is retrieved using the where clause
condition: to obtain one object you must reference the objectId
of the record in the where clause
property.
Important
For a detailed description of all input parameters see the Basic Object Retrieval topic of this guide.
After the Codeless logic runs, the operation returns the parent object
containing three related children objects:
The example below retrieves all parent objects and the corresponding related children objects from the data table:
After the Codeless logic runs, the operation returns two parent objects containing related children records: