in src/QLDBKVS.ts [259:292]
async getValue(key: string, withVersionNumber?: boolean): Promise<object | Buffer> {
const fcnName = "[QLDBKVS.getValue]";
const self: QLDBKVS = this;
const ledgerName: string = self.ledgerName;
const tableName: string = self.tableName;
const paramId: string = key;
const startTime: number = new Date().getTime();
try {
if (!key) {
throw new Error(`${fcnName}: Please specify a key`);
}
logger.debug(`${fcnName} Getting ${paramId} from ledger ${ledgerName} and table ${tableName} into a JSON object. (Expecting utf8 encoded string)`);
const result = await this.getValues([key], withVersionNumber);
const valueObject = result[0];
if (!valueObject) {
throw `Requested document does not exist`;
}
return valueObject;
} catch (err) {
const msg = `Requested document does not exist`;
logger.error(`${fcnName} ${msg}: ${err}`);
throw new Error(msg);
} finally {
const endTime: number = new Date().getTime();
logger.debug(`${fcnName} Execution time: ${endTime - startTime}ms`)
}
}