Update Existing Data
POST
/api/collections/data/updateUpdate Document data
To update some fields of a document without overwriting the entire document, use the following language-specific update()
methods:
You can pass in the new data as a JSON object to the update()
method. The update()
method will merge the new data with the existing data in the document.
curl --request POST \
--url https://api.worqhat.com/api/collections/data/update \
--header 'Authorization: Bearer <API KEY>' \
--header 'Content-Type: application/json' \
--data '{
"collection": "Sample Collection",
"docId": "sampleDocumentId",
"data": {
"name": "Jane Doe",
}
}'
Update Nested JSON Data in a Document
To replace the entire nested JSON object
To replace the entire nested JSON object, use the update()
method and pass in the new nested JSON object as the value of the key you want to update.
curl --request POST \
--url https://api.worqhat.com/api/collections/data/update \
--header 'Authorization: Bearer <API KEY>' \
--header 'Content-Type: application/json' \
--data '{
"collection": "Sample Collection",
"docId": "sampleDocumentId",
"data": {
"nestedJSON": {
"keyName1": "Value",
"keyName2": "Value",
},
"name": "Jane Doe",
}
}'
To update a specific key in the nested JSON object
To update a specific key in the nested JSON object, use the update()
method and pass in the new value of the key as a dot notation object
you want to update.
You can pass the specific key in the JSON and we will update the value of the key in the nested JSON object.
curl --request POST \
--url https://api.worqhat.com/api/collections/data/update \
--header 'Authorization: Bearer <API KEY>' \
--header 'Content-Type: application/json' \
--data '{
"collection": "Sample Collection",
"docId": "sampleDocumentId",
"data": {
"nestedJSON": {
"keyName1": "Value",
},
"name": "Jane Doe",
}
}'
Request
This is optional. DocId is the document identifier. You can choose to add your own docId or we will generate a random string
{
"collection": "testdata2",
"data": {
"uid": "user123",
"orgId": "1fe0a9ac-617a-42e4-a376-37808b98fc99",
"Company": "subscription",
"count": 5,
"metadata": {
"name": "John Doe",
"age": 30,
"address": {
"street": "123 Main St",
"city": "New York",
"country": "USA"
}
}
},
"docId": "user123"
}
Request samples
Responses
{
"message": "Data updated successfully",
"processingTime": 664.818458,
"processingId": "e23a3c4f-998a-4f1a-a474-080bc7fa4d1a"
}