Fetch Items from NoSQL Table
Catalyst enables you to fetch items from a NoSQL table by identifying them with their primary keys. For instance, you can use just the partition key or a combination of the partition key and sort key to fetch the item. You can also optionally filter the attributes to be fetched by specifying the required attributes.
The example below illustrates fetching an item identified by its partition key fruit with the value “apple” using fetchItem(). Specific attributes such as properties and taste are filtered to be fetched using required_attributes.
The code snippet also uses consistent_read to indicate if the read operation must be done using the master or a slave cluster. When set to true, it is queried from the master. If false, it is queried from the slave.
The no-sql library from the zcatalyst-sdk-node package is required to define the NoSQL item.
copyconst { NoSQLItem } = require('zcatalyst-sdk-node/lib/no-sql'); //Fetch properties of a NoSQLItem identified with the partition key value "apple" const fetchedItem = await table.fetchItem({ // Define the partition key and value of the item to be fetched keys: [new NoSQLItem().addString('fruit', 'apple')], // Set consistent_read to true to query from master. If set to false, it is queried from slave. consistent_read: true, // Specify the attributes to be fetched required_attributes: [['properties', 'taste']] });
Last Updated 2025-06-20 16:21:48 +0530 +0530
Yes
No
Send your feedback to us