Interface: ReadTransaction
ReadTransactions are used with query and subscribe and allows read operations on the database.
Hierarchy
ReadTransaction
Properties
clientID
• Readonly
clientID: string
environment
• Readonly
environment: TransactionEnvironment
Deprecated
Use location instead.
location
• Readonly
location: TransactionEnvironment
Methods
get
▸ get(key
): Promise
<undefined
| ReadonlyJSONValue
>
Get a single value from the database. If the key
is not present this
returns undefined
.
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.
Parameters
Name | Type |
---|---|
key | string |
Returns
Promise
<undefined
| ReadonlyJSONValue
>
▸ get<T
>(key
): Promise
<undefined
| DeepReadonly
<T
>>
Type parameters
Name | Type |
---|---|
T | extends JSONValue |
Parameters
Name | Type |
---|---|
key | string |
Returns
Promise
<undefined
| DeepReadonly
<T
>>
has
▸ has(key
): Promise
<boolean
>
Determines if a single key
is present in the database.
Parameters
Name | Type |
---|---|
key | string |
Returns
Promise
<boolean
>
isEmpty
▸ isEmpty(): Promise
<boolean
>
Whether the database is empty.
Returns
Promise
<boolean
>
scan
▸ scan(options
): ScanResult
<IndexKey
, 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.
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.
Parameters
Name | Type |
---|---|
options | ScanIndexOptions |
Returns
ScanResult
<IndexKey
, ReadonlyJSONValue
>
▸ scan(options?
): ScanResult
<string
, ReadonlyJSONValue
>
Parameters
Name | Type |
---|---|
options? | ScanNoIndexOptions |
Returns
ScanResult
<string
, ReadonlyJSONValue
>
▸ scan(options?
): ScanResult
<string
| IndexKey
, ReadonlyJSONValue
>
Parameters
Name | Type |
---|---|
options? | ScanOptions |
Returns
ScanResult
<string
| IndexKey
, ReadonlyJSONValue
>
▸ scan<V
>(options
): ScanResult
<IndexKey
, DeepReadonly
<V
>>
Type parameters
Name | Type |
---|---|
V | extends ReadonlyJSONValue |
Parameters
Name | Type |
---|---|
options | ScanIndexOptions |
Returns
ScanResult
<IndexKey
, DeepReadonly
<V
>>
▸ scan<V
>(options?
): ScanResult
<string
, DeepReadonly
<V
>>
Type parameters
Name | Type |
---|---|
V | extends ReadonlyJSONValue |
Parameters
Name | Type |
---|---|
options? | ScanNoIndexOptions |
Returns
ScanResult
<string
, DeepReadonly
<V
>>
▸ scan<V
>(options?
): ScanResult
<string
| IndexKey
, DeepReadonly
<V
>>
Type parameters
Name | Type |
---|---|
V | extends ReadonlyJSONValue |
Parameters
Name | Type |
---|---|
options? | ScanOptions |
Returns
ScanResult
<string
| IndexKey
, DeepReadonly
<V
>>