Skip to content

Delete Relation using condition

The API deletes objects from a relationship with their parent. The objects are identified implicitly through a whereClause condition.

Method

DELETE

URL

https://api.backendless.com/<application-id>/<REST-api-key>/data/<table-name>/<parentObjectId>/<relationName>?whereClause=<whereClause> 

where:

Argument                Description
<application-id> the ID of your application generated upon its creation. You can obtain the value in the Manage > App Settings section of the Backendless Console.
<REST-api-key> REST API key of your application. You can obtain the value in the Manage > App Settings section of the Backendless Console.
<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 with the child objects will be deleted.
<relationName> name of the column which identifies the relation within the parent table (identified as <table-name>).
<whereClause> a where clause condition identifying objects in the child table which will be removed from the relation to the parent object.

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-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.

Request Body

None

Return Value

Number of child objects removed from the relationship.

Example

The following request deletes a relation between a Person object and all the related objects in the related table (Users) which match the provided query. The column name identifying the relation is friends. The query is specified in the whereClause parameter in the URL. The value of the whereClause parameter is URL-encoded. The decoded version of the query is: name='Joe' or name = 'Frank'. As a result of the operation, all related objects where the name property is either Joe or Frank will be deleted from the relation.

curl \  
-X DELETE  
https://api.backendless.com/application-id/REST-api-key/data/Person/parentObjectId/friends?whereClause=name%3D%27Joe%27%20or%20name%20%3D%20%27Frank%27