Lightning.Collaboration.DocumentState (Lightning v2.15.0-pre5)
View SourceSchema for persisting Y.js collaborative document states.
Supports multiple record types for batched persistence:
- "update": Individual or batched updates
- "checkpoint": Full document state snapshot
- "state_vector": Current state vector for efficient syncing
Summary
Functions
Applies persisted state (checkpoint + updates) to a Yex document.
Retrieves the latest checkpoint and all updates since that checkpoint for a given document.
Retrieves the latest checkpoint for a document, or nil if none exists.
Retrieves all updates for a document inserted after the given timestamp, ordered chronologically (oldest first).
Loads all persisted state for a document and applies it to a Yex document.
Types
@type t() :: %Lightning.Collaboration.DocumentState{ __meta__: term(), document_name: String.t() | nil, id: integer() | nil, inserted_at: DateTime.t() | nil, state_data: binary() | nil, state_vector: binary() | nil, updated_at: DateTime.t() | nil, version: :update | :checkpoint | :state_vector | nil }
Functions
Applies persisted state (checkpoint + updates) to a Yex document.
Applies the checkpoint first (if present), then all updates in chronological order.
Retrieves the latest checkpoint and all updates since that checkpoint for a given document.
Returns {:ok, checkpoint, updates} where checkpoint may be nil,
or {:error, :not_found} if no persisted state exists.
Retrieves the latest checkpoint for a document, or nil if none exists.
@spec get_updates_since(String.t(), DateTime.t()) :: [t()]
Retrieves all updates for a document inserted after the given timestamp, ordered chronologically (oldest first).
Loads all persisted state for a document and applies it to a Yex document.
Convenience function that combines get_checkpoint_and_updates/1 and
apply_to_doc/3.