Readonly[Query objects.
ReadonlyregistryRegistry for this database. Delegates type lookups to the shared hypergraph registry.
To persist a schema so it replicates to other clients, add the type entity with
addType (e.g. await db.addType(Type.makeObjectFromJsonSchema(...))).
Adds an object or relation to the database.
Only Object and Relation entities are accepted. To persist a Type definition use addType — passing a Type entity is rejected at compile time (and at runtime).
Pass { to: feed } to append to a feed instead (synchronous; confirm with flush).
Optionalopts: AddOptionsPersists a Type definition (clones/forks the entity) so it replicates to other peers.
Runs a conflict query first: if a type with the same typename + version already exists in this space, the existing persisted entity is returned and no duplicate is created. This is the only supported way to add Type entities — add rejects them.
Optionalopts: WriteOptionsStarts staging structural changes that commit atomically; see Migration.Transaction.
Optionaloptions: TransactionOptionsWhen the database cannot commit with the chosen Migration.TransactionOptions.root.
Create a caller-owned, writable binding to one branch of one object — a live object whose reads
resolve the branch document and whose writes land on the branch document only. Multiple bindings
to different branches of the same object may coexist; the device-global current branch and other
bindings are unaffected. Binding to 'main' returns the canonical live object. Bindings are
ephemeral and never persisted — the caller must dispose().
Hashes and uploads bytes via the chosen storage backend, returning an un-added Blob object.
Rejects with Error.BlobTooLargeError (over inline storage's fixed cap, or the backend's own
maxSize), Error.BlobWriteError (backend upload failure), or Error.BlobNotAvailableError
(reason: 'backend-not-registered' — the requested storage name has no registered backend).
Optionaloptions: { storage?: string; type?: string }Adopts bytes already staged by a direct upload, returning an un-added Blob object.
Unlike createBlob the bytes never enter this process: they were written straight to the store by whoever held the upload URL, which is the point — the uploader is typically an agent's shell moving a file far too large to pass through a model. Size and content type therefore come back from the store rather than from the caller.
Rejects with Error.BlobNotAvailableError (reason: 'backend-not-registered' when the storage
name has no backend, 'not-found' when the backend cannot adopt uploads or the upload is gone)
or Error.BlobWriteError if adoption fails.
Optionaloptions: { storage?: string }Fork the object and its referenced subtree into a new branch (does not switch to it).
Optionalopts: { fromHeads?: readonly string[] | Record<string, readonly string[]> }OptionalfromHeads?: readonly string[] | Record<string, readonly string[]>Fork from a historical frontier instead of the tip (a bare heads array applies to the root only; a map forks each member from its own frontier).
Disposes and drops the in-memory handle (live working-set / core cache) for a feed, so the next
access re-reads it cold. Advanced cache-control; primarily used by tests to model a spawned
process reading the feed with an empty in-memory cache. Public (not _-prefixed) so it survives
declaration stripping for cross-package test use.
Wait for all pending changes to be saved to disk. Optionaly waits for changes to be propagated to indexes and event handlers.
Optionalopts: FlushOptionsAppends base as the base block of a new branch of the feed, with the fork point at (an item,
at the block it was read from, or a block id) as its predecessor. Resolves to the id of the new
branch, the block id of the base, once the base is written.
The object's history, oldest first: one entry per document change that touched the object (or,
given property, that property). Prefer Obj.getChanges(obj, opts).
Optionalopts: GetChangesOptions<string>The device-global current branch for an object id ('main' by default).
Return object by local ID.
Optionalopts: GetObjectByIdOptionsUse db.query(Filter.id(id)).runSync()[0] for a working-set lookup, or resolve via a Ref.
Get the current combined (automerge documents + feed blocks) sync state, reported against a single remote peer.
Optionaloptions: GetSyncStateOptionsCreates a reference to an existing object in the database.
NOTE: The reference may be dangling if the object is not present in the database.
NOTE: Difference from Ref.fromURI
Ref.fromURI(dxn) returns an unhydrated reference. The .load and .target APIs will not work.
db.makeRef(dxn) is preferable in cases with access to the database.
Removes object from the database.
Optionalopts: WriteOptionsRemoves feed items by ID. branches names the branch of each item by index (null for the root),
for an item this client holds no live copy of; without it such an item is removed from the root branch.
Replaces the set of objects the space directory tracks, dropping everything not retained.
Derived from the directory's own maps, so clearing a space costs one change rather than a scan of its contents. The objects are dropped, not soft-deleted: they are gone from the space and their documents are reclaimed by garbage collection, on this peer and — as the change replicates — on every other. Permanent; there is nothing left to restore from.
Ids of the objects dropped from the directory.
Reclaim storage held by soft-deleted objects and the documents / feed blocks that are no longer
reachable. Per-space and destructive; intended as an occasional/administrative call. See
garbage-collection design notes in @dxos/echo-host.
Optionaloptions: GarbageCollectionOptionsPer-space storage metrics: objects (alive/deleted), automerge documents, feeds, feed blocks.
Read-only. Intended as an occasional/administrative call. See garbage-collection design notes
in @dxos/echo-host.
Subscribe to combined sync state changes.
Optionaloptions: GetSyncStateOptionsFold main's changes into a branch across the subtree (the reverse of mergeBranch).
Syncs a feed with the server.
Optionaloptions: SyncOptions
ECHO Database interface.