Spatial Data Delete API¶
There are two way to delete a spatial value from an object in the database:
- Using Backendless Console
- Using API
Deleting Data with Console¶
To delete a spatial value in console, simply clear out the contents of a cell and press Enter
. Backendless Console confirms that the object has been updated:
Deleting Data with the API¶
Deleting a spatial value from an object using the API is technically the object update operation with the spatial value property set to null
. The example is a request which removes a value from the location
property for an object in the Person
table shown above. Notice the location property in the request is set to null
:
Important
Make sure to replace xxxx in the domain name in the sample request below to the one assigned to your application.
curl \
-X PUT \
-H 'Content-Type:application/json' \
-d '{ \
"location": null \
}' \
'https://xxxx.backendless.app/api/data/Person/OBJECTID'
Alternatively, the same result can be achieved using the bulk update API operation. With this approach you can delete a spatial property either in a single or multiple objects. This is done with a query (the where clause) used in the API request. For example, the following query uniquely identifies a single object: objectId = 'XXX-XXX-XXX'
. Consider an example demonstrating the approach:
curl -X PUT \
-H 'Content-Type:application/json' \
-d '{ "location":null }' \
'https://api.backendless.com/APP-ID/REST-API-KEY/data/bulk/Person?where=email%20%3D%20%27bob%40thebuilder.com%27'
Codeless Reference
Consider the following records stored in the data table called geolocation
:
Suppose you need to remove the geolocation data from the record, while leaving the value in the location
column "blank". Note, that when there is no value in the column and it is "blank", the column actually contains the null
value. So to delete the contents of the record, we must update the value in a specific column to the null
. The example below "deletes" the current geolocation data only for one object.
where:
Argument | Description |
---|---|
table name |
Name of the data table where a new record must be deleted(updated). |
object |
An object to save in the database. Object properties must match the names of the table columns. |
return result |
Optional parameter. When this box is checked, the operation returns the deleted(updated) object with the objectId property. |
After the operation runs, the value gets deleted(replaced with the null
value).
To delete geolocation data for multiple records, you have to use the Bulk Update
Codeless block. In this case you must establish the where clause
condition to allow the operation to find objects that must be delete(updated). As it was described above, the deletion result is achieved when a column is updated with the null
value. The null
indicates that a specific column contains no value.
The example below deletes the geolocation data for two objects in the data table. The where clause property contains the following condition:
objectId = 'E0236915-54CE-45DE-AC65-6F2093AC6ADF' OR objectId = 'F77A8ACE-EF6E-405F-9B31-E495E897D0D6'
As you can see, we have to reference two objectId
values and also use the OR
operator.
where:
Argument | Description |
---|---|
table name |
Name of the data table where records must be deleted(updated). |
where clause |
A condition which references a column name and a specific value in the data table where an update/deletion has to be carried out. Refer to the Search With The Where Clause topic for more information. |
changes |
This parameter expects an object that must contain the name of the column and a new value to update the existing contents with. |
Return count of updated objects |
Optional parameter. When this box is checked, the operation returns the number of deleted(updated) objects. |
The operation has successfully deleted(updated) the contents in the location
column for two objects.