async getMetadataByDocIdAndTxId()

in src/QLDBKVS.ts [527:557]


    async getMetadataByDocIdAndTxId(documentId: string, transactionId: string): Promise<LedgerMetadata> {
        const fcnName = "[QLDBKVS.getMetadataByDocIdAndTxId]";
        const self: QLDBKVS = this;
        const ledgerName: string = self.ledgerName;
        const tableName: string = self.tableName;
        const startTime: number = new Date().getTime();
        try {

            logger.debug(`${fcnName} Getting metadata for document id: ${documentId} and transaction id: ${transactionId} from ledger ${ledgerName} and table ${tableName} into a JSON object`);

            const result: LedgerMetadata = await this.qldbDriver.executeLambda(async (txn: TransactionExecutor) => {
                return await getDocumentLedgerMetadataByDocIdAndTxId(txn, this.ledgerName, tableName, documentId, transactionId, qldbClient).catch((err) => {
                    throw err
                });
            })

            if (!result) {
                throw `Requested document does not exist`;
            }

            return result;

        } catch (err) {
            const msg = `Could not get metadata`;
            logger.error(`${fcnName} ${msg}: ${err}`);
            throw new Error(msg);
        } finally {
            const endTime: number = new Date().getTime();
            logger.debug(`${fcnName} Execution time: ${endTime - startTime}ms`)
        }
    }