Loading...

Update Item

Description

This API enables you to update an item from the existing data in a NoSQL table in your project. The table is referred to by its unique ID or name.

You can pass the attributes to be updated with or without specifying any conditions in the Custom JSON format.

Request Details

Request URL

PUT

{api-domain}/baas/v1/project/{{project_id}}/nosqltable/{{table_identifier}}/item

copy

api-domain
URL
The DC-specific domain to access Catalyst API

project_id
Numerical
The unique ID of the project

table_identifier
Numerical
The unique ID of the table or table name

Request Headers

Authorization: Zoho-oauthtoken {oauth_token}
Content-Type: application/json

Optional Headers

CATALYST-ORG: {org_id}

Environment: Development

Scope

ZohoCatalyst.nosql.item.UPDATE

Note: This operation can also be executed with Catalyst user authentication permissions using Catalyst SDKs. Refer to the Catalyst API Prerequisites section for details.

Request JSON Properties

keys json
mandatory
Denotes the partition key and sort key of the table.
update_attributes json
mandatory

Denotes the attribute to be updated along with its value. The update can be of two types: PUT (to add a new attribute within the item) and DELETE (to remove an attribute from the item). The attribute_path indicates the path within the item where the actual operation is to be done. The value to be updated can be of two types:

update_value json
mandatory
The actual value to be updated.

update_function json
optional

There are four functions that can be used:
if_not_exists - Checks the existence of the attribute and declares a value if it is not present. append_list - Appends data to a list add - Adds a value along with existing value or adds an element in a set reduction - Subtracts a value from existing value or removes an element in a set.


condition json
optional

The existing data of the table is retrieved and evaluated against this condition. The items are inserted only if the evaluation is true. If there is no existing data, the conditions are ignored and the items are inserted. There are three ways to initialize a condition:

functions json
mandatory (if specifying condition)
The two built-in functions are: attribute_exist, which can be used to check for the presence of an attribute, and attribute_type, which can be used to check if the given attribute name belongs to the given type.

operator, attribute, value json
optional
To perform direct comparison operations. Supported operators: contains, not_contains, begins_with, ends_with, in, not_in, between, not_between, equals, not_equals, greater_than, less_than, greater_equal, less_equal.

group, group operator json
optional
To combine two or more conditions. Supported group operators: and, or.

negate json
optional
To negate the result of the conditions.

Response Details

The response will return the status of the insert operation, as well as the details of the item updated such as the table_name, partition_key and sort_key, if configured.

Sample Request
copy

curl -X PUT
https://api.catalyst.zoho.com/baas/v1/project/4000000006007/nosqltable/3376000003171728/item
-H “Authorization: Zoho-oauthtoken 1000.910*************************16.2f*************************57”
-H “Content-Type:application/json”
-d ‘{ keys:{ partition_key:{ “S”:“Country” }, sort_key:{ “N”:“EmpID” }, } update_attributes:{ “item”: { “EmpID”: { “N”: “10999” }, “FirstName”:{ “S”: “Paul” }, “LastName”:{ “S”: “Smith” }, “PriorExperience”:{ “BOOL”: false }, “Location”: { “M”: { “Country”: { “S”: “USA” }, “City”: { “S”: “New York” } } } } } }’

Sample Response
copy
{
"status": "success",
"data": {
    "table_name": "employeeDetails",
    "project_details": {
        "id": 4000000006007,
        "project_name": "EmpDatabase",
        "project_type": "Live"
    }
}
}