[]
Defines the interface for a database adapter in operational transformation.
| Name | Type | Description |
|---|---|---|
S |
unknown |
The type of snapshot data. |
T |
unknown |
The type of operation data. |
▸ close(): Promise<void>
Closes the database connection.
Promise<void>
A promise that resolves when the database is closed.
▸ commitOp(id, op, document, options?): Promise<boolean>
Commits an operation to the database.
| Name | Type | Description |
|---|---|---|
id |
string |
The document ID. |
op |
IOp<T> |
The operation to commit. |
document |
IDocument |
The document metadata. |
options? |
unknown |
- |
Promise<boolean>
A promise resolving to true if the operation was committed, false otherwise.
▸ commitSnapshot(id, snapshot, options?): Promise<boolean>
Commits a snapshot to the database.
| Name | Type | Description |
|---|---|---|
id |
string |
The document ID. |
snapshot |
ICommitSnapshot<S> |
The snapshot to commit. |
options? |
unknown |
- |
Promise<boolean>
A promise resolving to true if the snapshot was committed, false otherwise.
▸ getCommittedOpVersion(id, to, op): Promise<null | number>
Retrieves the committed version of an operation, if it exists.
| Name | Type | Description |
|---|---|---|
id |
string |
The document ID. |
to |
number |
The ending version to check up to. |
op |
IOp<unknown> |
The operation to verify. |
Promise<null | number>
A promise resolving to the committed version or null if not committed.
▸ getDocument(id, options?): Promise<null | IDocument>
Retrieves document information by ID.
| Name | Type | Description |
|---|---|---|
id |
string |
The document ID. |
options? |
unknown |
- |
Promise<null | IDocument>
A promise resolving to the document info or null if not found.
▸ getFragment(id, fragmentId, options?): Promise<null | { data: null | S ; version: number }>
Retrieves a specific fragment of a document by ID.
| Name | Type | Description |
|---|---|---|
id |
string |
The document ID. |
fragmentId |
string |
The ID of the fragment. |
options? |
unknown |
- |
Promise<null | { data: null | S ; version: number }>
| null>} Resolves to an object with fragment version and data, or null if the document does not exist. If the document exists but the fragment does not, data is null.
▸ getOps(id, from, to?, options?): Promise<IOp<T>[]>
Retrieves operations between two versions (inclusive of 'from', exclusive of 'to').
| Name | Type | Description |
|---|---|---|
id |
string |
The document ID. |
from |
number |
The starting version. |
to? |
number |
- |
options? |
unknown |
- |
Promise<IOp<T>[]>
A promise resolving to an array of operations.
▸ getSnapshot(id, options?): Promise<null | ISnapshot<S>>
Retrieves the snapshot of a document by ID.
| Name | Type | Description |
|---|---|---|
id |
string |
The document ID. |
options? |
unknown |
- |
Promise<null | ISnapshot<S>>
A promise resolving to the snapshot or null if not found.