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
Codeless Reference¶
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 |
You must use the where clause condition in this property to delete specific children objects 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
:
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:
Suppose, you want to delete only one relation. The example below deletes the Objective-C
relation from the data table using the where clause condition "skill = 'Objective-C'"
specified in the children
property:
The result of this operation is one deleted relation Objective-C
from the data table:
In case you want to delete multiple objects relations using the where clause condition, refer to the example below which removes all relations except the Java
.
After the Codeless Logic runs, only one object relation Java
remains in the data table.