Skip to content

setTransactionData

setTransactionData(key, value): void

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

Attach some arbitrary user data to the current transaction context, which is attached to the currently running (async) task.

symbol

A symbol key to store data in the current transaction context.

any

The value to store.

void

If called outside of a transaction context.

const MY_SYMBOL = Symbol("myKey");
await transact(async () => {
setTransactionData(MY_SYMBOL, "myValue");
await somethingAsync(); // Can be interleaved with other transactions
const value = getTransactionData(MY_SYMBOL);
console.log(value); // "myValue"
});