Insert NoSQL Items in Table

Catalyst enables you to insert items in a specific NoSQL table after you construct them. The items can be inserted in different ways as described in this section.

You can refer to the help sections on adding and working with data, the Catalyst custom JSON format, and the supported data types to learn these topics in detail.

Note: Catalyst enables you to insert a maximum of 25 items in bulk in a NoSQL table with a single SDK operation.

Insert Items without Conditions

You can insert new items into a NoSQL table without any conditions either by using the ZCNoSQLTable instance, or the ZCNoSQLInsertHelper instance which can be used to construct the various parts of the request.

You can insert data with the ZCNoSQLTable instance as shown below.

    
copy
//public ZCNoSQLResponseBean insert(ZCNoSQLItem item) throws Exception; table.insert(<ZCNoSQLItem>);

You can insert data with the ZCNoSQLInsertHelper instance as shown below.

    
copy
//public ZCNoSQLInsertHelper getInsertHelper(ZCNoSQLItem item) throws Exception; //public ZCNoSQLResponseBean insert() throws Exception; table.getInsertHelper(<ZCNoSQLItem>).insert();

This class can be used to insert data into a table with conditions. This can be obtained from ZCNoSQLTable instance.


Insert Items with Conditions

You can insert attributes in existing items in a NoSQL table using specific conditions that you define. In this type, the existing data of the table is retrieved and evaluated against the specified 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.

The snippet below shows inserting items with conditions using ZCNoSQLCondition.

    
copy
//public ZCNoSQLInsertHelper withCondition(ZCNoSQLCondition condition) throws Exception; table.getInsertHelper(<ZCNoSQLItem>).withCondition(<ZCNoSQLCondition>).insert();

Condition can be passed with the help of ZCNoSQLCondition instance which can be obtained by using a constructor or calling the getInstance() method. Conditions can be initialized in 3 methods

1. Using functions

    
copy
//public static ZCNoSQLCondition getInstance(NoSQLConditionFunction function) throws Exception; //public ZCNoSQLCondition(NoSQLConditionFunction function) throws Exception; ZCNoSQLCondition.getInstance(<NoSQLCondtitionFunction>); new ZCNoSQLCondition(<NoSQLCondtitionFunction>)

There are two built in-functions available.

i. ZCNoSQLAttributeTypeFunction

Check if the data type of the given attribute matched the given datatype.

    
copy
//public ZCNoSQLAttributeTypeFunction(ZCNoSQLAttribute attribute, ZCNoSQLValue.DataType dataType) throws Exception; //public static ZCNoSQLAttributeTypeFunction getInstance(ZCNoSQLAttribute attribute, ZCNoSQLValue.DataType dataType) throws Exception; ZCNoSQLAttributeTypeFunction.getInstance(<ZCNoSQLAttribute>, <ZCNoSQLValue.DataType>); new ZCNoSQLAttributeTypeFunction(<ZCNoSQLAttribute>, <ZCNoSQLValue.DataType>);

ii. ZCNoSQLAttributeExistFunction

This is used to evaluate if an attribute already exists in the retrieved item.

    
copy
//public ZCNoSQLAttributeExistFunction(ZCNoSQLAttribute attribute); //public static ZCNoSQLAttributeExistFunction getInstance(ZCNoSQLAttribute attribute); ZCNoSQLAttributeExistFunction.getInstance(<ZCNoSQLAttribute>); new ZCNoSQLAttributeExistFunction(<ZCNoSQLAttribute>)

2. Using operator, operand and value

    
copy
//public static ZCNoSQLCondition getInstance(ZCNoSQLAttribute attribute, NOSQL_OPERATOR operator, ZCNoSQLValue value) throws Exception; //public ZCNoSQLCondition(ZCNoSQLAttribute attribute, NOSQL_OPERATOR operator, ZCNoSQLValue value) throws Exception; ZCNoSQLCondition.getInstance(<ZCNoSQLAttribute>, <NOSQL_OPERATOR>, <ZCNoSQLValue>); new ZCNoSQLCondition(<ZCNoSQLAttribute>, <NOSQL_OPERATOR>, <ZCNoSQLValue>);

NOSQL_OPERATOR

The allowed NOSQL_OPERATOR values are contains, not_contains, begins_with, ends_with, in, not_in, between, not_between, equals, not_equals, greater_than, less_than, greater_equal, less_equal

Using group of conditions

    
copy
//public static ZCNoSQLCondition getInstance(List<ZCNoSQLCondition> groups, NOSQL_CONDITION_GROUP_OPERATOR groupOperator) throws Exception; //public ZCNoSQLCondition(List<ZCNoSQLCondition> groups, NOSQL_CONDITION_GROUP_OPERATOR groupOperator) throws Exception; ZCNoSQLCondition.getInstance(List<ZCNoSQLCondition>,<NOSQL_CONDITION_GROUP_OPERATOR>) new ZCNoSQLCondition(List<ZCNoSQLCondition>,<NOSQL_CONDITION_GROUP_OPERATOR>)

NOSQL_CONDITION_GROUP_OPERATOR

The allowed NOSQL_CONDITION_GROUP_OPERATOR values are AND, OR

NOSQL_RETURN_VALUE

Indicates the return value after evaluating condition.

    
copy
//public ZCNoSQLInsertHelper withReturnValue(NOSQL_RETURN_VALUE returnValue) throws Exception table.getInsertHelper(<ZCNoSQLItem>).withReturnValue(<NOSQL_RETURN_VALUE>).insert();

The allowed NOSQL_RETURN_VALUE values are NEW, OLD, NULL

Insert with Condition and Return Value

    
copy
table.getInsertHelper(<ZCNoSQLItem>).withCondition(<ZCNoSQLCondition>).withReturnValue(<NOSQL_RETURN_VALUE>).insert();

Last Updated 2025-06-20 16:21:48 +0530 +0530