in src/GetDocument.ts [107:135]
export async function getByKeyAttributes(txn: TransactionExecutor, tableName: string, keyAttributeName: string, keyAttributeValues: string[]): Promise<GetDocumentResult[]> {
const fcnName = "[GetDocument.getByKeyAttributes]"
const startTime: number = new Date().getTime();
try {
validateTableNameConstrains(tableName);
validateAttributeNameConstrains(keyAttributeName);
const query = `SELECT data, metadata.version FROM _ql_committed_${tableName} AS d WHERE d.data.${keyAttributeName} IN ${getBindParametersString(keyAttributeValues.length)}`;
if (keyAttributeValues.length > MAX_KEYS_TO_RETRIEVE) throw `Maximum number of keys (${MAX_KEYS_TO_RETRIEVE}) exceeded.`
logger.debug(`${fcnName} Retrieving document values for Keys: ${keyAttributeValues}`);
logger.debug(`${fcnName} Query statement: ${query}`);
const result: Result = await txn.execute(query, ...keyAttributeValues)
const endTime = new Date().getTime();
logger.debug(`${fcnName} Execution time: ${endTime - startTime}ms`)
const resultList: dom.Value[] = result.getResultList();
if (resultList.length === 0) {
throw `${fcnName} Unable to find documents with keys: ${keyAttributeValues}.`;
}
return prepareGetDocumentResult(resultList);
} catch (err) {
const endTime: number = new Date().getTime();
logger.debug(`${fcnName} Execution time: ${endTime - startTime}ms`)
throw err;
}
}