Remove data from Array
POST
/api/collections/data/array/update/removeLast modified: 5 months ago
Update Elements in an Array
Update Elements in an Array by adding new element or removing an existing element in the array.
If your document contains an array field, you can use arrayUnion()
and arrayRemove()
to add and remove elements. arrayUnion()
adds elements to an array but only elements not already present. arrayRemove()
removes all instances of each given element.
:::warning
The Array Update operation is only available for Array fields and will only work if the Field has either been declared during a Add
operation or has been updated with a Update
operation. If the Field doesn't exist, the Array Update operation will fail.
:::
Add Elements to an Array
To add elements to an array field, use the arrayUnion()
method:
curl --request POST \
--url https://api.worqhat.com/api/collections/data/array/update/add \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"collection": "Sample Collection",
"docId": "sampleDocId",
"field": "sampleField",
"arrayUnion": "sampleData"
}'
Remove Elements from an Array
To remove elements from an array field, use the arrayRemove()
method:
curl --request POST \
--url https://api.worqhat.com/api/collections/data/array/update/remove \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"collection": "Sample Collection",
"docId": "sampleDocId",
"field": "sampleField",
"arrayRemove": "sampleData"
}'
Request
Body Params application/json
collection
string
required
docId
string
required
field
string
required
arrayRemove
string
required
Example
{
"collection": "",
"docId": "78220c06-d20b-4c87-9004-86051bbbc712",
"field": "testArray2",
"arrayRemove": "test 1"
}
Request samples
Responses
OK(200)
Server Error(500)
HTTP Code: 200
Content Type : JSONapplication/json
Data Schema
message
string
required
processingTime
number
required
processingId
string
required
Example
{
"message": "Array data added successfully",
"processingTime": 334.394875,
"processingId": "cb44a695-b24f-4863-b01e-26735b39397c"
}
Last modified: 5 months ago