Skip to main content

Interface: WriteTransaction#

WriteTransactions are used with mutators which are registered using ReplicacheOptions.mutators and allows read and write operations on the database.

Hierarchy#

Methods#

del#

del(key: string): Promise<boolean>

Removes a key and its value from the database. Returns true if there was a key to remove.

Parameters:#

NameType
keystring

Returns: Promise<boolean>

Defined in: transactions.ts:156


get#

get(key: string): Promise<undefined | JSONValue>

Get a single value from the database. If the key is not present this returns undefined.

Parameters:#

NameType
keystring

Returns: Promise<undefined | JSONValue>

Inherited from: ReadTransaction

Defined in: transactions.ts:23


has#

has(key: string): Promise<boolean>

Determines if a single key is present in the database.

Parameters:#

NameType
keystring

Returns: Promise<boolean>

Inherited from: ReadTransaction

Defined in: transactions.ts:26


isEmpty#

isEmpty(): Promise<boolean>

Whether the database is empty.

Returns: Promise<boolean>

Inherited from: ReadTransaction

Defined in: transactions.ts:29


put#

put(key: string, value: JSONValue): Promise<void>

Sets a single value in the database. The value will be encoded using JSON.stringify.

Parameters:#

NameType
keystring
valueJSONValue

Returns: Promise<void>

Defined in: transactions.ts:150


scan#

scan<O, K>(options?: O): ScanResult<K>

Gets many values from the database. This returns a ScanResult which implements AsyncIterable. It also has methods to iterate over the keys and entries.

If options has an indexName, then this does a scan over an index with that name. A scan over an index uses a tuple for the key consisting of [secondary: string, primary: string].

If the ScanResult is used after the ReadTransaction has been closed it will throw a TransactionClosedError.

Type parameters:#

NameType
OScanOptions
KScanOptionIndexedStartKey

Parameters:#

NameType
options?O

Returns: ScanResult<K>

Inherited from: ReadTransaction

Defined in: transactions.ts:43


scanAll#

scanAll<O, K>(options?: O): Promise<[K, JSONValue][]>

Convenience form of scan which returns all the entries as an array.

deprecated Use scan().entries().toArray() instead

Type parameters:#

NameType
OScanOptions
KScanOptionIndexedStartKey

Parameters:#

NameType
options?O

Returns: Promise<[K, JSONValue][]>

Inherited from: ReadTransaction

Defined in: transactions.ts:51