Increment/Decrement Count
POST
/api/collections/data/incrementThere are three ways to add data to a WorqDB Collection:
- Set the Data of a Document within a Collection, with an automatically generated document identifier or
docId
. - Add a Document with a custom
docId
to identify your document within a Collection. - Create an empty document with an automatically generated identifier, and assign data to it later. You can do this by using the
create
method and then theupdate
method later on.
:::highlight yellow 💡
In this we have focused on the API Endpoints but you can also use our NodeJS Packages to integrate with your Javascript
and Typescript
package.
:::
Before you begin
See Get started with Create Collections to create a Collection before you add data to it.
Set the Data of a Document within a Collection
You can add data to a Collection by using the add
method. This method will create a new document with an automatically generated document identifier or docId
.
curl --request POST \
--url https://api.worqhat.com/api/collections/data/add \
--header 'Authorization: Bearer <API KEY>' \
--header 'Content-Type: application/json' \
--data '{
"collection": "Sample Collection",
"data": {
"name": "John Doe",
"Company": "Acme Corp",
"Login": 1697359974
}
}'
Try it out in the API Reference
Visit the API Reference to learn how to Add Documents in your projects. Get
access to
Sample Code, API Endpoints and run it right within the browser to test it out.
Add a Document with a custom docId
You can add data to a Collection by using the add
method. This method will create a new document with a custom docId
that you can use to identify your document within a Collection.
curl --request POST \
--url https://api.worqhat.com/api/collections/data/add \
--header 'Authorization: Bearer <API KEY>' \
--header 'Content-Type: application/json' \
--data '{
"collection": "Sample Collection",
"docId": "sampleDocumentId",
"data": {
"name": "John Doe",
"Company": "Acme Corp",
"Login": 1697359974
}
}'
Try it out in the API Reference
Visit the API Reference to learn how to Add Documents with a Custom Document Id in your projects. Get
access to
Sample Code, API Endpoints and run it right within the browser to test it out.
Create an empty document with an automatically generated identifier, and assign data to it later
You can create an empty document with an automatically generated identifier, and assign data to it later by using the update
method. This method will create a new document with an automatically generated document identifier or docId
and the Document Creation Timestamp.
curl --request POST \
--url https://api.worqhat.com/api/collections/data/add \
--header 'Authorization: Bearer <API KEY>' \
--header 'Content-Type: application/json' \
--data '{
"collection": "Sample Collection",
"docId": "thisIsOptionalString",
"data": {}
}'
Try it out in the API Reference
Visit the API Reference to learn how to Add Documents with a Custom Document Id in your projects. Get
access to
Sample Code, API Endpoints and run it right within the browser to test it out.
Request
{
"collection": "testdata2",
"docId": "user123",
"field": "count",
"increment": 10
}
Request samples
Responses
{
"message": "Data count incremented successfully",
"processingTime": 483.261917,
"processingId": "707695c8-7c7c-4864-9414-619d89b729d0"
}