Skip to main content

Interface: ReadTransaction

ReadTransactions are used with Replicache.query and Replicache.subscribe and allows read operations on the database.

Hierarchy#

Properties#

clientID#

Readonly clientID: string

Methods#

get#

get(key): Promise<undefined | ReadonlyJSONValue>

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

Parameters#

NameType
keystring

Returns#

Promise<undefined | ReadonlyJSONValue>


has#

has(key): Promise<boolean>

Determines if a single key is present in the database.

Parameters#

NameType
keystring

Returns#

Promise<boolean>


isEmpty#

isEmpty(): Promise<boolean>

Whether the database is empty.

Returns#

Promise<boolean>


scan#

scan(): ScanResult<string, ReadonlyJSONValue>

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.

Returns#

ScanResult<string, ReadonlyJSONValue>

scan<Options, Key>(options?): ScanResult<Key, ReadonlyJSONValue>

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
Optionsextends ScanOptions
Keyextends string | [secondary: string, primary: string]

Parameters#

NameType
options?Options

Returns#

ScanResult<Key, ReadonlyJSONValue>