Update Parent and Child¶
The example below demonstrates how the Deep Save API can be used to update both the parent and the child objects in the database. The sample retrieves a Product
and the related Manufacturer
objects then it changes property values in both objects and saves the changes with a single Deep Save API call. The objects before the code runs are:
The Product
object:
The Manufacturer
object:
curl \
-H Content-Type:application/json \
-X PUT \
-d "{
\"objectId\":"748471BF-F2E7-4AF0-A60C-68291B52999F\",
\"price\":1300,
\"manufacturer\" : {
\"objectId\":\"8494BFCC-964E-4F7F-95E3-2497C5D34011\",
\"industry\":\"Computer Hardware, Software and Consumer Electronics\"
}
}" \
-v https://xxxx.backendless.app/api/data/Product/deep-save
Server response:
{
"price": 1300,
"created": 1624090691000,
"name": "iPhone X",
"___class": "Product",
"ownerId": null,
"updated": 1624094140000,
"objectId": "748471BF-F2E7-4AF0-A60C-68291B52999F",
"manufacturer": {
"created": 1624090692000,
"name": "Apple",
"___class": "Manufacturer",
"industry": "Computer Hardware, Software and Consumer Electronics",
"ownerId": null,
"updated": 1624094140000,
"objectId": "8494BFCC-964E-4F7F-95E3-2497C5D34011"
}
}
Codeless reference:
After the sample code runs, the objects in the database will appear as shown below:
The Product
object:
The Manufacturer
object: