[]
        
(Showing Draft Content)

Db

Class: Db<S, T>

Abstract base class implementing the database adapter interface.

Type parameters

Name Description
S The type of snapshot data.
T The type of operation data.

Hierarchy

Implements

Table of contents

Constructors

Methods

Constructors

constructor

new Db<S, T>()

Type parameters

Name
S
T

Methods

close

Abstract close(): Promise<void>

Closes the database connection.

Returns

Promise<void>

Implementation of

IDatabaseAdapter.close


commitOp

Abstract commitOp(id, op, document, options?): Promise<boolean>

Commits an operation to the database.

Parameters

Name Type
id string
op IOp<T>
document IDocument
options? unknown

Returns

Promise<boolean>

Implementation of

IDatabaseAdapter.commitOp


commitSnapshot

Abstract commitSnapshot(id, snapshot, options?): Promise<boolean>

Commits a snapshot to the database.

Parameters

Name Type
id string
snapshot ICommitSnapshot<S>
options? unknown

Returns

Promise<boolean>

Implementation of

IDatabaseAdapter.commitSnapshot


getCommittedOpVersion

getCommittedOpVersion(id, to, op): Promise<null | number>

Retrieves the committed version of an operation if it exists.

Parameters

Name Type
id string
to number
op IOp<object>

Returns

Promise<null | number>

Implementation of

IDatabaseAdapter.getCommittedOpVersion


getDocument

Abstract getDocument(id, options?): Promise<null | IDocument>

Retrieves document information by ID.

Parameters

Name Type
id string
options? unknown

Returns

Promise<null | IDocument>

Implementation of

IDatabaseAdapter.getDocument


getFragment

Abstract getFragment(id, fragmentId, options?): Promise<null | { data: null | S ; version: number }>

Retrieves a specific fragment of a document by ID.

Parameters

Name Type
id string
fragmentId string
options? unknown

Returns

Promise<null | { data: null | S ; version: number }>

Implementation of

IDatabaseAdapter.getFragment


getOps

Abstract getOps(id, from, to?, options?): Promise<IOp<T>[]>

Retrieves operations between two versions (inclusive of 'from', exclusive of 'to').

Parameters

Name Type
id string
from number
to? number
options? unknown

Returns

Promise<IOp<T>[]>

Implementation of

IDatabaseAdapter.getOps


getSnapshot

Abstract getSnapshot(id, options?): Promise<null | ISnapshot<S>>

Retrieves the snapshot of a document by ID.

Parameters

Name Type
id string
options? unknown

Returns

Promise<null | ISnapshot<S>>

Implementation of

IDatabaseAdapter.getSnapshot