RxDB Server

Interfaces

Interfaces

ReplicationClientOptions

Properties:

PropertyTypeRequiredDescription
databaseEpicFlowDatabaseYesLocal RxDB database to sync
remoteUrlstringYesRemote WebSocket URL to connect to
collectionsstring[] | undefinedNoCollections to replicate (if not specified, replicates all)

ServerInstance

Server instance returned by createServer

Properties:

PropertyTypeRequiredDescription
rxServeranyYes
databaseEpicFlowDatabaseYes

AuthData

Properties:

PropertyTypeRequiredDescription
type"service" | "jwt" | "api_token"Yes
userIdstring | undefinedNo
serviceAccountIdstring | undefinedNo
emailstring | undefinedNo
domainIdstringYes
orgIdstring | undefinedNo
scopesstring[]Yes
tokenNamestring | undefinedNo

AuthValidatorConfig

Properties:

PropertyTypeRequiredDescription
tokenManagerTokenManagerYes
storageAuthStorageAdapterYes
domainIdstringYes
internalAuthTokenstring | undefinedNo

CollectionReplicationStatus

Status of a collection's replication

Properties:

PropertyTypeRequiredDescription
collectionNamestringYesCollection name
activebooleanYesWhether replication is currently active
pushednumberYesNumber of documents pushed to remote
pullednumberYesNumber of documents pulled from remote
lastErrorstring | nullYesLast error message (if any)
lastSyncnumber | nullYesTimestamp of last successful sync

RemoteReplicationConfig

Remote RxDB server replication configuration types

Properties:

PropertyTypeRequiredDescription
enabledbooleanYesEnable or disable remote replication

When true, this server will connect to the remote server and sync data. When false, the server operates in standalone mode. | | url | string | Yes | Remote RxDB server WebSocket URL

The WebSocket endpoint of the remote RxDB server to sync with. Must use wss:// protocol for production, ws:// for local testing. | | authToken | string | Yes | JWT authentication token for remote server

A valid JWT token issued by the remote server's authentication system. The token must include claims for domainId, scopes (read/write), and expiration. | | domainId | string | Yes | Domain ID to sync with remote server

Only documents with this domainId will be replicated. Must match a domain that exists on both local and remote servers. | | syncInterval | number | Yes | Sync interval in milliseconds

How often to check for new changes from the remote server. Lower values provide more real-time sync but increase network usage. | | live | boolean | Yes | Enable live (real-time) replication

When true, changes are synced immediately via WebSocket connection. When false, sync only happens at the interval specified by syncInterval. | | retryTime | number | Yes | Retry delay on connection failure (milliseconds)

How long to wait before retrying a failed WebSocket connection. Uses exponential backoff for subsequent retries. | | pushBatchSize | number | Yes | Batch size for push operations

Number of documents to batch together when pushing changes to remote server. Higher values are more efficient but use more memory. | | collections | string[] \| undefined | No | Collections to replicate (optional)

If specified, only these collections will be replicated. If empty or undefined, all collections are replicated. | | excludeCollections | string[] \| undefined | No | Collections to exclude from replication (optional)

Collections listed here will NOT be replicated. Takes precedence over collections if both are specified. |

LoggerConfig

Properties:

PropertyTypeRequiredDescription
levelLogLevelYes
prefixstring | undefinedNo
timestampboolean | undefinedNo
colorsboolean | undefinedNo

WebSocketAuthContext

WebSocket authentication context returned after successful authentication

Properties:

PropertyTypeRequiredDescription
data{ domainId: string; permissions: string[]; userId?: string; serviceAccountId?: string; }Yes
validUntilnumberYes

WebSocketServerOptions

Configuration options for WebSocket server attachment

Properties:

PropertyTypeRequiredDescription
httpServerhttp.Server<typeof http.IncomingMessage, typeof http.ServerResponse>YesHTTP server instance to attach WebSocket upgrade handler to
databaseEpicFlowDatabaseYesRxDB database instance containing collections for replication
pathstring | undefinedNoWebSocket server path for upgrade endpoint

WebSocketServerState

WebSocket server state returned from attachment Provides methods to control the WebSocket server lifecycle

Properties:

PropertyTypeRequiredDescription
close() => Promise<void>YesClose the WebSocket server and disconnect all clients

DocumentChange

Change event for a single document modification.

Properties:

PropertyTypeRequiredDescription
documentRxDocumentData<RxDocType>YesThe document after the change.
metadataDocumentMetadataYesDocument metadata including sequence number.
operation"INSERT" | "UPDATE" | "DELETE"YesType of operation that caused the change.
previousRxDocumentData<RxDocType> | undefinedNoThe document before the change (for updates).
undefined for inserts.

FilesystemStorageOptions

Configuration options for filesystem storage.

Properties:

PropertyTypeRequiredDescription
basePathstringYesBase directory path where database files will be stored.
Each collection will have its own subdirectory.

DocumentMetadata

Internal document metadata tracked by the storage engine.

Properties:

PropertyTypeRequiredDescription
sequencenumberYesMonotonically increasing sequence number for change tracking.
Used for implementing checkpoints and change feeds.
lastModifiedstringYesISO 8601 timestamp when the document was last modified.
deletedbooleanYesWhether this document has been deleted (tombstone).

CollectionMetadata

Collection-level metadata stored in .meta.json file.

Properties:

PropertyTypeRequiredDescription
collectionNamestringYesName of the collection.
currentSequencenumberYesCurrent sequence number - incremented on each write.
createdAtstringYesISO 8601 timestamp when the collection was created.
lastModifiedstringYesISO 8601 timestamp when metadata was last updated.
schemaVersionnumberYesSchema version of the collection.

EventFile

Event data written to .events/ directory for multi-instance sync.

Properties:

PropertyTypeRequiredDescription
pidnumberYesProcess ID that generated this event.
timestampstringYesISO 8601 timestamp when event was created.
documentIdsstring[]YesDocument IDs that were modified.
sequenceRange{ start: number; end: number; }YesSequence number range affected by this event.

CacheEntry

In-memory document cache entry.

Properties:

PropertyTypeRequiredDescription
documentRxDocumentData<RxDocType>YesThe document data.
metadataDocumentMetadataYesDocument metadata.
lastAccessnumberYesWhen this entry was last accessed (for LRU eviction).

Checkpoint

Checkpoint used for pagination of change feeds.

Properties:

PropertyTypeRequiredDescription
sequencenumberYesSequence number up to which changes have been consumed.
idstringYesDocument ID at this sequence (for stable ordering).

BulkWriteResult

Result of a bulk write operation.

Properties:

PropertyTypeRequiredDescription
successRxDocumentData<RxDocType>[]YesDocuments that were successfully written.
error{ document: RxDocumentData<RxDocType>; isConflict: boolean; error: Error; }[]YesDocuments that failed to write due to conflicts or errors.

StorageInstanceState

Internal storage state for each instance.

Properties:

PropertyTypeRequiredDescription
collectionPathstringYesBase path for this collection's data.
metaPathstringYesPath to the .meta.json file.
eventsPathstringYesPath to the .events/ directory.
cacheMap<string, CacheEntry<RxDocType>>YesIn-memory document cache (LRU).
maxCacheSizenumberYesMaximum cache size (number of documents).
closedbooleanYesWhether this instance has been closed.
metadataCollectionMetadataYesCollection metadata (loaded from disk).
Previous
API Reference
Next
Types