Class Database<DT>

Type Parameters

  • DT extends DocTypes = NonNullable<unknown>

Implements

  • Connectable

Constructors

  • Type Parameters

    • DT extends {} = {}

    Parameters

    • Optionalname: string
    • Optionalopts: ConfigOpts

    Returns Database<DT>

Properties

_crdt: CRDT<DT>
_listeners: Set<ListenerFn<DT>> = ...
_listening: boolean = false
_noupdate_listeners: Set<ListenerFn<DT>> = ...
_ready: ResolveOnce = ...
_writeQueue: WriteQueue<DT>
blockstore: BaseBlockstore
logger: Logger
name?: string
opts: ConfigOpts = {}
sthis: SuperThis
databases: Map<string, Database> = ...

Methods

  • Returns Promise<void>

  • Parameters

    • updates: DocUpdate<{}>[]

    Returns Promise<void>

  • Type Parameters

    • T extends {}

    Parameters

    • opts: AllDocsQueryOpts = {}

    Returns Promise<AllDocsResponse<T>>

  • Type Parameters

    • T extends {}

    Returns Promise<{ clock: ClockHead; rows: { key: string; value: DocWithId<T> }[] }>

  • Type Parameters

    • T extends {}

    Parameters

    • since: ClockHead = []
    • opts: ChangesOptions = {}

    Returns Promise<ChangesResponse<T>>

  • Close the database and release resources

    Returns Promise<void>

  • delete a document from the database

    Parameters

    • id: string

      Document id

    Returns Promise<DocResponse>

    DocResponse with the id and clock

  • Destroy the database and release all resources

    Returns Promise<void>

  • Get a document from the database

    Type Parameters

    • T extends {}

    Parameters

    • id: string

      the document id

    Returns Promise<DocWithId<T>>

    the document with the _id

    NotFoundError if the document is not found

  • Put a document from the database

    Type Parameters

    • T extends {}

    Parameters

    • doc: DocSet<T>

      the document to put

    Returns Promise<DocResponse>

    add DocResponse with the id and clock

  • Type Parameters

    • K extends IndexKeyType
    • T extends {}
    • R extends DocFragment = T

    Parameters

    • field: string | MapFn<T>
    • opts: QueryOpts<K> = {}

    Returns Promise<IndexRows<K, T, R>>

  • Type Parameters

    • T extends {}

    Parameters

    • listener: ListenerFn<T>
    • Optionalupdates: boolean

    Returns () => void