Skip to content

transact

transact<T>(fn): Promise<number>

Defined in: .work/repos/olmdb/src/olmdb.ts:294

Executes a function within a database transaction context.

All database operations (get, put, del) must be performed within a transaction. Transactions are automatically committed if the function completes successfully, or aborted if an error occurs. Failed transactions may be automatically retried up to 6 times in case of validation conflicts.

T

The return type of the transaction function.

() => Promise<typeof RETURN_COMMIT_SEQ>

The (optionally asynchronous) function to execute within the transaction context.

Promise<number>

A promise that resolves with the function’s return value. If the function returns the special symbol RETURN_COMMIT_SEQ, the promise resolves with the commit sequence number instead.

If nested transactions are attempted.

With code “RACING_TRANSACTION” if the transaction fails after retries due to conflicts.

With code “TRANSACTION_FAILED” if the transaction fails for other reasons.

With code “TXN_LIMIT” if maximum number of transactions is reached.

With code “LMDB-{code}” for LMDB-specific errors.

const result = await transact(() => {
const value = get(keyBytes);
if (value) {
put(keyBytes, newValueBytes);
}
return value;
});

transact<T>(fn): Promise<number>

Defined in: .work/repos/olmdb/src/olmdb.ts:295

Executes a function within a database transaction context.

All database operations (get, put, del) must be performed within a transaction. Transactions are automatically committed if the function completes successfully, or aborted if an error occurs. Failed transactions may be automatically retried up to 6 times in case of validation conflicts.

T

The return type of the transaction function.

() => typeof RETURN_COMMIT_SEQ

The (optionally asynchronous) function to execute within the transaction context.

Promise<number>

A promise that resolves with the function’s return value. If the function returns the special symbol RETURN_COMMIT_SEQ, the promise resolves with the commit sequence number instead.

If nested transactions are attempted.

With code “RACING_TRANSACTION” if the transaction fails after retries due to conflicts.

With code “TRANSACTION_FAILED” if the transaction fails for other reasons.

With code “TXN_LIMIT” if maximum number of transactions is reached.

With code “LMDB-{code}” for LMDB-specific errors.

const result = await transact(() => {
const value = get(keyBytes);
if (value) {
put(keyBytes, newValueBytes);
}
return value;
});

transact<T>(fn): Promise<T>

Defined in: .work/repos/olmdb/src/olmdb.ts:296

Executes a function within a database transaction context.

All database operations (get, put, del) must be performed within a transaction. Transactions are automatically committed if the function completes successfully, or aborted if an error occurs. Failed transactions may be automatically retried up to 6 times in case of validation conflicts.

T

The return type of the transaction function.

() => Promise<T>

The (optionally asynchronous) function to execute within the transaction context.

Promise<T>

A promise that resolves with the function’s return value. If the function returns the special symbol RETURN_COMMIT_SEQ, the promise resolves with the commit sequence number instead.

If nested transactions are attempted.

With code “RACING_TRANSACTION” if the transaction fails after retries due to conflicts.

With code “TRANSACTION_FAILED” if the transaction fails for other reasons.

With code “TXN_LIMIT” if maximum number of transactions is reached.

With code “LMDB-{code}” for LMDB-specific errors.

const result = await transact(() => {
const value = get(keyBytes);
if (value) {
put(keyBytes, newValueBytes);
}
return value;
});

transact<T>(fn): Promise<T>

Defined in: .work/repos/olmdb/src/olmdb.ts:297

Executes a function within a database transaction context.

All database operations (get, put, del) must be performed within a transaction. Transactions are automatically committed if the function completes successfully, or aborted if an error occurs. Failed transactions may be automatically retried up to 6 times in case of validation conflicts.

T

The return type of the transaction function.

() => T

The (optionally asynchronous) function to execute within the transaction context.

Promise<T>

A promise that resolves with the function’s return value. If the function returns the special symbol RETURN_COMMIT_SEQ, the promise resolves with the commit sequence number instead.

If nested transactions are attempted.

With code “RACING_TRANSACTION” if the transaction fails after retries due to conflicts.

With code “TRANSACTION_FAILED” if the transaction fails for other reasons.

With code “TXN_LIMIT” if maximum number of transactions is reached.

With code “LMDB-{code}” for LMDB-specific errors.

const result = await transact(() => {
const value = get(keyBytes);
if (value) {
put(keyBytes, newValueBytes);
}
return value;
});