Updating multiple objects.
By using the an operations parameter, you can update multiple objects at once. As with single object updating, you should use the PUT method, (there is no need to specify the object ID).
Note
See the full list of supported operators, and read more about the operations parameters here.
https://api.appery.io/rest/1/db/collections/<collectionName>/
curl -X PUT
-H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9"
-H "Content-Type: application/json"
-d 'operations={"$set":{"studentId":60}}'
https://api.appery.io/rest/1/db/collections/students/
Example
By mixing the where and operations parameters, you can conditionally update multiple objects. Only objects that satisfy the where condition will be updated.
The query below finds all of the records where studentId equals 20 and changes it to 60.
curl -X PUT
-H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9"
-H "Content-Type: application/json"
-d 'where={"studentId":20}'
-d 'operations={"$set":{"studentId":60}}'
https://api.appery.io/rest/1/db/collections/students/
Also, an update parameter is available when updating multiple objects. You can specify what fields the object should be updated in, and the values to change them.
Note
If the operations object is specified then the update parameter is fully ignored. Their functionality can not be used simultaneously.
The following example finds all of the records where the studentId equals 20, and changes studentName field to 60:
curl -X PUT
-H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9"
-H "Content-Type: application/json"
-d 'where={"studentId":20}'
-d 'update={"studentName":60}'
https://api.appery.io/rest/1/db/collections/students/
Note
Read more about the where and operations parameters.
Updating arrays and pointers is also available for the update parameter. If we assume that your collection contains a column user with a pointer type to _users collection, you can update the marks column type of array.
curl -X PUT
-H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9"
-H "Content-Type: application/json"
-d 'where={"studentId":20}'
-d 'update={"user": {"collName":"_users", "_id":"5540ed6ae4b020ea2fabaf44"}, "marks":{"__op":"AddUnique","objects":[5, 2]}}'
https://api.appery.io/rest/1/db/collections/students/