[]
        
(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>

A promise that resolves when the database is closed.

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>

A promise resolving to true if the operation was committed, false otherwise.

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>

A promise resolving to true if the snapshot was committed, false otherwise.

Implementation of

IDatabaseAdapter.commitSnapshot


getCommittedOpVersion

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

Retrieves the committed version of an operation if it exists.

Parameters

Name Type
id string
to number
op IOp<object>

Returns

Promise<undefined | number>

Implementation of

IDatabaseAdapter.getCommittedOpVersion


getDocument

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

Retrieves document information by ID.

Parameters

Name Type
id string
options? unknown

Returns

Promise<undefined | null | IDocument>

A promise resolving to the document info or undefined/null if not found.

Implementation of

IDatabaseAdapter.getDocument


getFragment

Abstract getFragment(id, fragmentId, options?): Promise<undefined | null | S>

Retrieves a specific fragment of a document by ID.

Parameters

Name Type
id string
fragmentId string
options? unknown

Returns

Promise<undefined | null | S>

A promise resolving to the fragment data or undefined/null if not found.

Implementation of

IDatabaseAdapter.getFragment


getFragments

Abstract getFragments(id, fragmentIds?, options?): Promise<{ [id: string]: S; }>

Retrieves multiple fragments of a document by ID.

Parameters

Name Type
id string
fragmentIds? string[]
options? unknown

Returns

Promise<{ [id: string]: S; }>

} A promise resolving to an object mapping fragment IDs to their data.

Implementation of

IDatabaseAdapter.getFragments


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>[]>

A promise resolving to an array of operations.

Implementation of

IDatabaseAdapter.getOps


getSnapshot

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

Retrieves the snapshot of a document by ID.

Parameters

Name Type
id string
options? unknown

Returns

Promise<undefined | null | ISnapshot<S>>

A promise resolving to the snapshot or undefined/null if not found.

Implementation of

IDatabaseAdapter.getSnapshot