Construct NoSQL Item
Catalyst NoSQL items represent a collection of attributes that hold the data of a single data point, like records. You can insert or update items into an existing NoSQL table in your project in a Custom JSON format. However, before you insert or update an item in Catalyst, you will need to construct the item.
You can construct a NoSQL item of attributes containing different data types supported by Catalyst as described in the section below. Catalyst supports several data types such as String, Number, Set of Strings, Set of Numbers, List, and Map. Refer to the full list of supported data types to learn more.
You must mandatorily provide the values for the partition key attribute that you configured for a table in every data item. Refer to the Table Keys help section to learn about the table keys, TTL attribute, and other details.
Create a New NoSQL Item
You can create a new NoSQL item using the NoSQLItem() method after requiring the no-sql library which is a part of the zcatalyst-sdk-node package, as shown below.
copyconst { NoSQLItem } = require('zcatalyst-sdk-node/lib/no-sql'); const item = new NoSQLItem() // Create a new NoSQL item
Construct a NoSQL Item of String
In the example below, we construct an item that includes string values and a nested JSON attribute color as a Map.
copyconst { NoSQLItem } = require('zcatalyst-sdk-node/lib/no-sql'); const item = new NoSQLItem() // Create a new NoSQL item // Add a string value .addString('fruit', 'mango') // Add a map .addMap('properties', { color: 'yellow' });
Construct a NoSQL Byte
You can create a NoSQL byte to store values of the Binary data type, by creating a buffer object that is used to represent a sequence of bytes. You can then create a byte in two ways as shown below: using the ArrayBuffers object that represents a raw binary data buffer, or from a Base64 string that represents binary data in the ASCII format.
copyconst { NoSQLByte } = require('zcatalyst-sdk-node/lib/no-sql'); // Create a NoSQL Byte const buff = Buffer.from('Hello world !!!'); // Create a buffer object const byte = new NoSQLByte(buff); // Create a NoSQL byte using the ArrayBuffers object const byteA = new NoSQLByte(buff.toString('base64')); // Create a NoSQL byte from a Base64 string
Construct a NoSQL Byte Set
Catalyst enables you to create a NoSQL byte set to store a collection of binary values of the Set of Binary data type, by creating a buffer object that is used to represent a sequence of bytes. You can then create a byte set by using the ArrayBuffers object that represents a raw binary data buffer, or from a Base64 string that represents binary data in the ASCII format.
You can also create a byte set from passing constructed bytes as a byte array.
copyconst { NoSQLByte, NoSQLByteSet } = require('zcatalyst-sdk-node/lib/no-sql'); // Create a NoSQL Byte Set const buff = Buffer.from('Hello world !!!'); // Create a buffer object const byte = new NoSQLByte(buff); // Create a NoSQL byte using the ArrayBuffers object const byteA = new NoSQLByte(buff.toString('base64')); // Create a NoSQL byte from a Base64 string const byteSet = new NoSQLByteSet([byte, byteA]); // Create a NoSQL byte set from a NoSQL byte array const byteSetA = new NoSQLByteSet([buff.toString('base64')]); // Create a NoSQL Byte set from a Base64 string array const byteSetB = new NoSQLByteSet([buff]); // Create a NoSQL Byte set using the ArrayBuffers object
Construct a NoSQL String Set
You can create a NoSQL string set of the Set of String data type from a string array as shown below.
copyconst { NoSQLStringSet } = require('zcatalyst-sdk-node/lib/no-sql'); // Create a NoSQL string set const stringSet = new NoSQLStringSet(['hello', 'world']); // Create a NoSQL string set from a string array
Construct a NoSQL Number Set
You can create NoSQL number set of the Set of Numbers data type from an array of numbers or BigInt values as shown below.
copyconst { NoSQLNumberSet } = require('zcatalyst-sdk-node/lib/no-sql'); // Create a NoSQL number set const numberSet = new NoSQLNumberSet([123, 1234n]); // Create a NoSQL Number set from an array of numbers or BigInt values
Manipulate NoSQL Items
Catalyst enables you to perform manipulations on a NoSQL items, such as creating a NoSQL item from a plain JavaScript object, or vice versa. You can create a NoSQL item by constructing a plain JavaScript object that contains the item’s data in it, in the standard JSON format. You can then construct the NoSQL item from the JS object using NoSQLItem.from() as shown in the sample code below.
You can also convert a NoSQL item back into a plain JavaScript object using itemFromObj.to(), as depicted in the code.
copyconst { NoSQLItem } = require('zcatalyst-sdk-node/lib/no-sql'); // Define an object const obj = { fruit: 'apple', // Partition key properties: { color: 'red' } }; const itemFromObj = NoSQLItem.from(obj); // Construct a NoSQL item from the plain JS object const plainJsObject = itemFromObj.to(); // Convert the item to a plain JS object
Last Updated 2025-06-20 16:21:48 +0530 +0530
Yes
No
Send your feedback to us