[]
        
(Showing Draft Content)

IDatabaseAdapter

Interface: IDatabaseAdapter<S, T>

Defines the interface for a database adapter in operational transformation.

Type parameters

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

Implemented by

Table of contents

Methods

Methods

close

close(): Promise<void>

Closes the database connection.

Returns

Promise<void>

A promise that resolves when the database is closed.


commitOp

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

Commits an operation to the database.

Parameters

Name Type Description
id string The document ID.
op IOp<T> The operation to commit.
document IDocument The document metadata.
options? unknown -

Returns

Promise<boolean>

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


commitSnapshot

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

Commits a snapshot to the database.

Parameters

Name Type Description
id string The document ID.
snapshot ICommitSnapshot<S> The snapshot to commit.
options? unknown -

Returns

Promise<boolean>

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


getCommittedOpVersion

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

Retrieves the committed version of an operation, if it exists.

Parameters

Name Type Description
id string The document ID.
to number The ending version to check up to.
op IOp<unknown> The operation to verify.

Returns

Promise<undefined | number>

A promise resolving to the committed version or undefined if not committed.


getDocument

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

Retrieves document information by ID.

Parameters

Name Type Description
id string The document ID.
options? unknown -

Returns

Promise<undefined | null | IDocument>

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


getFragment

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

Retrieves a specific fragment of a document by ID.

Parameters

Name Type Description
id string The document ID.
fragmentId string The ID of the fragment.
options? unknown -

Returns

Promise<undefined | null | S>

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


getFragments

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

Retrieves multiple fragments of a document by ID.

Parameters

Name Type Description
id string The document ID.
fragmentIds? string[] -
options? unknown -

Returns

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

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


getOps

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

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

Parameters

Name Type Description
id string The document ID.
from number The starting version.
to? number -
options? unknown -

Returns

Promise<IOp<T>[]>

A promise resolving to an array of operations.


getSnapshot

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

Retrieves the snapshot of a document by ID.

Parameters

Name Type Description
id string The document ID.
options? unknown -

Returns

Promise<undefined | null | ISnapshot<S>>

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