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

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>?whereClause=<whereClause> 

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

Important

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

curl \  
-X DELETE  
https://xxxx.backendless.app/api/data/Person/parentObjectId/friends?whereClause=name%3D%27Joe%27%20or%20name%20%3D%20%27Frank%27