Fetch Items from NoSQL TableAdmin Scope
Note: Ensure you have installed the required package to use this SDK method.
Using the fetchItem() SDK method, you can fetch the required items from a NoSQL table. The items can be referred using their Primary Keys. For example, you can use just the partition key or a combination of the partition key and sort key to fetch the item. Optionally, you can filter the attributes to be fetched by specifying the required attributes.
Note: Catalyst enables you to fetch a maximum of 100 items from a NoSQL table in a single SDK read operation.
The following example code snippet details the following logic:
- The required item is being identified using its partition key: fruit whose value is “apple”.
- Specific attributes such as properties and taste are filtered to be fetched using required_attributes.
- Implements consistent_read to indicate if the read operation must be done using the master or a slave cluster.
- If the value is set as true, it is queried from the master.
- If the value is set as false, it is queried from the slave.
Note: In the master-slave replication, the master contains all the data of the database, and the slave contains copies from the master. Performing a read operation from the slave can reduce the overall cost with the trade-off being a minor delay in the updated data being reflected.
copy
//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 2026-07-02 14:51:41 +0530 IST
Yes
No
Send your feedback to us
Skip
Submit