Skip to content

Delete Objects from relation

The API removes specific objects from a relationship with their parent.

Method

DELETE

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>/<parentObjectId>/<relationName> 

where:

Argument                Description
<table-name> Name of the table where which contains the parent object as identified by <parentObjectId>.
<parentObjectId> Id of the object for which the relation will be deleted.
<relationName> Name of the column which identifies the relation within the parent table (identified as <table-name>).

Request Headers

user-token: value-of-the-user-token-header-from-login  
Content-Type:application/json

where:

Argument                Description
user-token Optional header. Contains a value returned by Backendless in a preceding user Login API call. If user-token is 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 the roles assigned to the user will be enforced by Backendless.
Content-Type Must be set to application/json. This header is mandatory.

Request Body

Must be an array of child object IDs as string values.

[  
  "childObjectId1", "childObjectId2"  
]

Return Value

Error or number of objects the operation deleted for the relation.

Example

The example below deletes a relation between a Person object and its children. The child objects are referenced explicitly in the API call (see the object IDs in the body as "XXXXX-XXXXX-XXXXX-XXXXX" ``and`` "ZZZZ-ZZZZ-ZZZZZ-ZZZZZ").The relation column is address.

Important

Make sure to replace xxxx in the domain name in the sample request below to the one assigned to your application.

curl \  
-H Content-Type:application/json \  
-X DELETE  
-d "{ \"XXXXX-XXXXX-XXXXX-XXXXX\", \"ZZZZ-ZZZZ-ZZZZZ-ZZZZZ\" }" \  
https://xxxx.backendless.app/api/data/Person/parentObjectId/address

Codeless Reference

data_delete_object_where_clause

where:

Argument                Description
table name Name of the table where which contains the parent object as identified by parent object.
parent object Id of the object for which the relation will be deleted.
relation name Name of the column which identifies the relation within the parent table (identified as table name).
children Represents a list containing unique identifiers(objectIds) of the children objects relations that must be deleted from the data table.
return result When this box is checked, the operation returns the number of removed child objects relations.

Returns the number of removed child objects relations.

Consider the first object with one-to-many relations(skills column) in the parent data table called employees:
data_delete_object_from_relation_1

By clicking the record (1:N Relations) in the skills column of the parent data table presented above, you get redirected to the child data table called uniqueSkills, where you can see the related children objects:

data_delete_object_from_relation_2

Suppose you want to remove two relations. The following example demonstrates the removal of the Objective-C and Javascript relations from the parent object:

The objectId values for each relation are:

  1. Objective-C: "4E205196-59B0-45A6-BACB-303A66BEFF22"

  2. Javascript: "D08FA6A7-4534-4B43-AF06-BC4CBFE54C60"

data_delete_object_from_relation_3

After the operation runs, the Objective-C and Javascript relations get deleted.

data_delete_object_from_relation_4