Interface: WriteTransaction
WriteTransactions are used with mutators which are registered using ReplicacheOptions.mutators and allows read and write operations on the database.
Hierarchy
↳
WriteTransaction
Properties
clientID
• Readonly
clientID: string
Inherited from
Methods
del
▸ del(key
): Promise
<boolean
>
Removes a key
and its value from the database. Returns true
if there was a
key
to remove.
Parameters
Name | Type |
---|---|
key | string |
Returns
Promise
<boolean
>
get
▸ get(key
): Promise
<undefined
| JSONValue
>
Overrides ReadTransaction.get to return a mutable JSONValue.
Parameters
Name | Type |
---|---|
key | string |
Returns
Promise
<undefined
| JSONValue
>
Overrides
has
▸ has(key
): Promise
<boolean
>
Determines if a single key
is present in the database.
Parameters
Name | Type |
---|---|
key | string |
Returns
Promise
<boolean
>
Inherited from
isEmpty
▸ isEmpty(): Promise
<boolean
>
Whether the database is empty.
Returns
Promise
<boolean
>
Inherited from
put
▸ put(key
, value
): Promise
<void
>
Sets a single value
in the database. The value
will be encoded using
JSON.stringify
.
Parameters
Name | Type |
---|---|
key | string |
value | JSONValue |
Returns
Promise
<void
>
scan
▸ scan(): ScanResult
<string
, JSONValue
>
Overrides ReadTransaction.scan to return a mutable JSONValue.
Returns
ScanResult
<string
, JSONValue
>
Overrides
▸ scan<Options
>(options?
): ScanResult
<KeyTypeForScanOptions
<Options
>, JSONValue
>
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.
Important: The returned JSON is readonly and should not be modified. This is only enforced statically by TypeScript and there are no runtime checks for performance reasons. If you mutate the return value you will get undefined behavior.
Type parameters
Name | Type |
---|---|
Options | extends ScanOptions |
Parameters
Name | Type |
---|---|
options? | Options |
Returns
ScanResult
<KeyTypeForScanOptions
<Options
>, JSONValue
>