import { AuthorizedHttpClient } from '../utils/api-request'; import { ParsableComponent } from '../utils/pojo/common'; import { INoSQLDeleteItem, INoSQLFetchItem, INoSQLInsertItem, INoSQLQuery, INoSQLTable, INoSQLUpdateItem } from './types'; import NoSQLResponse from './response'; export default class NoSQLTable implements ParsableComponent { #private; constructor(requester: AuthorizedHttpClient, { tableDetails, tableId }: { tableDetails?: INoSQLTable; tableId?: string; }); /** * Insert items to the table * @param values values to be inserted * @returns NoSQL Response with create response * * @example * ```js * const { NoSQLItem } = require('zcatalyst-sdk/lib/no-sql'); * const insertedItems = await table.insertItems({ * // item to be inserted * item: NoSQLItem.from({ part_key: "a" }), * }); * ``` */ insertItems(...values: Array): Promise; /** * Update items in table * @param values items to be updated * @returns NoSQL Update with update response * * @example * ```js * const { NoSQLMarshall, NoSQLEnum } = require('zcatalyst-sdk/lib/no-sql'); * const { NoSQLUpdateOperationType } = NoSQLEnum; * // { * // 'part_key': 'a', * // 'info': null, <== update the { new_val: 'xyz' } value here * // } * const updatedItems = await table.updateItems({ * // partition key of the item to be updated * keys: new NoSQLItem().addString('part_key', 'a'), * // attributes to be updated * update_attributes: [ * { * // type of update operation * operation_type: NoSQLUpdateOperationType.PUT, * // value of the attribute to be updated * update_value: NoSQLMarshall.make({ new_val: 'xyz' }), * // path to the attribute * attribute_path: ['info'] * } * ] * }); * ``` */ updateItems(...values: Array): Promise; /** * Delete items from the table * @param values item to be deleted * @returns NoSQL Response with delete response * * @example * ```js * const { NoSQLItem } = require('zcatalyst-sdk/lib/no-sql'); * const deletedItem = await table.deleteItems({ * // partition key of the item to be deleted * keys: NoSQLItem.from({ fruit: 'apple' }) * }); * ``` */ deleteItems(...values: Array): Promise; /** * Fetch items from the table * @param value item to be fetched * @returns NoSQL Response with read response * * @example * const { NoSQLItem } = require('zcatalyst-sdk/lib/no-sql'); * const fetchedItem = await table.fetchItem({ * // partition key of the item to be fetched * keys: [new NoSQLItem().addString('part_key', 'a')], * // is consistent read enabled * consistent_read: true, * // attributes to be fetched * required_attributes: [['info', 'new_value']] * }); */ fetchItem(value: INoSQLFetchItem): Promise; /** * Query items from the table * @param query query to be executed * @returns NoSQL Response with read response * * @example * ```js * const { NoSQLEnum, NoSQLMarshall } = require('zcatalyst-sdk/lib/no-sql'); * const { NoSQLOperator } = NoSQLEnum; * const queriedItem = await table.queryTable({ * // condition to identify the item * key_condition: { * // NoSQL attribute path * attribute: ['info', 'new_value'], * // NoSQL operator * operator: NoSQLOperator.EQUALS, * // Value for comparison * value: NoSQLMarshall.makeString('xyz') * } * }); * ``` * */ queryTable(query: INoSQLQuery): Promise; /** * Query indexes of the table * @param indexId Id or Name of the NoSQL table index * @param query NoSQL Query to be executed * @returns NoSQL Response with read response * * @example * ```js * const { NoSQLEnum, NoSQLMarshall } = require('zcatalyst-sdk/lib/no-sql'); * const { NoSQLOperator } = NoSQLEnum; * // mention the index to be queried * const queriedIndexItems = await table.queryIndex('test-idx', { * // condition to identify the item * key_condition: { * // NoSQL attribute path * attribute: ['info', 'new_value'], * // NoSQL operator * operator: NoSQLOperator.EQUALS, * // Value for comparison * value: NoSQLMarshall.makeString('xyz') * } * }); * ``` */ queryIndex(indexId: string, query: INoSQLQuery): Promise; /** * * @throws **CatalystNoSQLError** with code `no_data` if the table details are not present */ toString(): string; /** * Get a json representation of the NoSQL table's details * @throws **CatalystNoSQLError** with code `no_data` if the table details are not present */ toJSON(): INoSQLTable; getComponentName(): string; }