Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface WriteTransaction

WriteTransactions are used with Replicache.register and allows read and write operations on the database.

Hierarchy

Index

Methods

createIndex

  • createIndex(__namedParameters: { jsonPointer: string; keyPrefix: undefined | string; name: string }): Promise<void>
  • Creates a persistent secondary index in Replicache which can be used with scan.

    If the named index already exists with the same definition this returns success immediately. If the named index already exists, but with a different definition an error is returned.

    Parameters

    • __namedParameters: { jsonPointer: string; keyPrefix: undefined | string; name: string }
      • jsonPointer: string
      • keyPrefix: undefined | string
      • name: string

    Returns Promise<void>

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

    • key: string

    Returns Promise<boolean>

dropIndex

  • dropIndex(name: string): Promise<void>
  • Drops an index previously created with createIndex.

    Parameters

    • name: string

    Returns Promise<void>

get

  • get(key: string): Promise<JSONValue | undefined>
  • Get a single value from the database. If the key is not present this returns undefined.

    Parameters

    • key: string

    Returns Promise<JSONValue | undefined>

has

  • has(key: string): Promise<boolean>
  • Determines if a single key is present in the database.

    Parameters

    • key: string

    Returns Promise<boolean>

put

  • put(key: string, value: JSONValue | ToJSON): Promise<void>
  • Sets a single value in the database. The value will be encoded using JSON.stringify.

    Parameters

    • key: string
    • value: JSONValue | ToJSON

    Returns Promise<void>

scan

  • scan(__namedParameters?: { indexName: undefined | string; limit: undefined | number; prefix: undefined | string; start: undefined | ScanBound }): ScanResult
  • Gets many values from the database. This returns a ScanResult which implements AsyncIterable. It also has methods to iterate over the keys and entries.

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

    Parameters

    • Optional __namedParameters: { indexName: undefined | string; limit: undefined | number; prefix: undefined | string; start: undefined | ScanBound }
      • indexName: undefined | string
      • limit: undefined | number
      • prefix: undefined | string
      • start: undefined | ScanBound

    Returns ScanResult

scanAll

  • scanAll(options?: ScanOptions): Promise<[string, JSONValue][]>
  • Convenience for scan() that reads all results into an array.

    Parameters

    • Optional options: ScanOptions

    Returns Promise<[string, JSONValue][]>

Generated using TypeDoc