ChangeLog
Defined in: libs/runtime/src/change-log.ts:184
A store’s change log: every committed change as a revision, in commit order, with each thing’s revision tree, its
conflicts, compaction, and the full-text index kept with it. Reached as db.changeLog. It is what
replicateOnce and TypeDBLiteReplicator read from and apply to.
Member summary
Section titled “Member summary”Properties
| Name | Description |
|---|---|
| fullText | Full-text search over the projected state (Goal 6). |
Methods
| Name | Description |
|---|---|
| applyRemote() | Apply a revision that originated elsewhere. |
| applyRemoteBatch() | Apply a batch of pushed revisions all or none, and return how many were new. |
| canonicalOf() | Canonical form of an entity’s current state — exposed for tests and diagnostics. |
| compact() | Drop revision history that nothing can read, keeping every leaf. |
| conflictsOf() | Every losing leaf — the equivalent of CouchDB’s _conflicts. |
| ensureSchema() | Creates the log’s tables if they do not exist, and migrates an older one. |
| identify() | Resolve a thing to its node-independent identity and state. |
| keyTypes() | The attribute types that carry @key. |
| leavesOf() | The leaves of an entity’s revision tree — every revision that is nobody’s parent. |
| projectWinner() | Make the winning revision visible to TypeQLite. |
| recordTombstone() | Record that a thing was deleted, as a tombstone revision. |
| recordWrite() | Record a write to the thing with this local iid, as a revision of its current state. |
| rememberKeys() | Remember which attribute types carry @key. |
| since() | Everything after cursor, in commit order. |
| stateOf() | The state a revision carried, if it carried any. |
| vacuum() | Return freed pages to the filesystem. |
| winnerOf() | The winning leaf, by ADR-003 D3’s total rule. |
Properties
Section titled “Properties”fullText
Section titled “fullText”
readonlyfullText:FullTextIndex
Defined in: libs/runtime/src/change-log.ts:186
Full-text search over the projected state (Goal 6). Kept current inside projection.
Methods
Section titled “Methods”applyRemote()
Section titled “applyRemote()”applyRemote(
record):boolean
Defined in: libs/runtime/src/change-log.ts:585
Apply a revision that originated elsewhere.
Its parent may be any revision in the tree, not the local winner — which is precisely how a
branch appears. Idempotent: UNIQUE (entity_id, rev) absorbs a revision delivered twice, which
an at-least-once transport will do.
Parameters
Section titled “Parameters”record
Section titled “record”deleted
Section titled “deleted”boolean
entityId
Section titled “entityId”string
parentRev?
Section titled “parentRev?”string | null
string
state?
Section titled “state?”Returns
Section titled “Returns”boolean
applyRemoteBatch()
Section titled “applyRemoteBatch()”applyRemoteBatch(
records):number
Defined in: libs/runtime/src/change-log.ts:664
Apply a batch of pushed revisions all or none, and return how many were new.
Parameters
Section titled “Parameters”records
Section titled “records”readonly object[]
Returns
Section titled “Returns”number
canonicalOf()
Section titled “canonicalOf()”canonicalOf(
iid):string|undefined
Defined in: libs/runtime/src/change-log.ts:817
Canonical form of an entity’s current state — exposed for tests and diagnostics.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”string | undefined
compact()
Section titled “compact()”compact(
options?):CompactionReport
Defined in: libs/runtime/src/change-log.ts:748
Drop revision history that nothing can read, keeping every leaf.
keepAncestors retains the most recent N non-leaf revisions per entity, for anyone who wants
a shallow tree rather than none. It defaults to 0, which is what a single node wants.
Parameters
Section titled “Parameters”options?
Section titled “options?”CompactionOptions = {}
Returns
Section titled “Returns”conflictsOf()
Section titled “conflictsOf()”conflictsOf(
id): readonlyLeaf[]
Defined in: libs/runtime/src/change-log.ts:346
Every losing leaf — the equivalent of CouchDB’s _conflicts.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”readonly Leaf[]
ensureSchema()
Section titled “ensureSchema()”ensureSchema():
void
Defined in: libs/runtime/src/change-log.ts:202
Creates the log’s tables if they do not exist, and migrates an older one. Safe to repeat.
Returns
Section titled “Returns”void
identify()
Section titled “identify()”identify(
iid):EntityIdentity|undefined
Defined in: libs/runtime/src/change-log.ts:248
Resolve a thing to its node-independent identity and state.
Returns undefined when the thing does not exist — which is normal, not an error: a delete
cascade may already have removed it.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”EntityIdentity | undefined
keyTypes()
Section titled “keyTypes()”keyTypes():
ReadonlySet<string>
Defined in: libs/runtime/src/change-log.ts:235
The attribute types that carry @key. loadSchema derives key ownerships from it for a database that predates schema_key_owns.
Returns
Section titled “Returns”ReadonlySet<string>
leavesOf()
Section titled “leavesOf()”leavesOf(
id): readonlyLeaf[]
Defined in: libs/runtime/src/change-log.ts:319
The leaves of an entity’s revision tree — every revision that is nobody’s parent.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”readonly Leaf[]
projectWinner()
Section titled “projectWinner()”projectWinner(
id):void
Defined in: libs/runtime/src/change-log.ts:489
Make the winning revision visible to TypeQLite.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
recordTombstone()
Section titled “recordTombstone()”recordTombstone(
identity):void
Defined in: libs/runtime/src/change-log.ts:412
Record that a thing was deleted, as a tombstone revision. Takes an identity captured before the delete ran, because afterwards there is nothing left to read.
Parameters
Section titled “Parameters”identity
Section titled “identity”Returns
Section titled “Returns”void
recordWrite()
Section titled “recordWrite()”recordWrite(
iid):void
Defined in: libs/runtime/src/change-log.ts:364
Record a write to the thing with this local iid, as a revision of its current state. Idempotent by construction: a revision is derived from its state and parent, so
re-recording an unchanged entity computes the same rev and the UNIQUE (entity_id, rev)
constraint absorbs it. That matters because one TypeQLite insert touches a thing, then each of its
attributes, then each of its roles — the same entity is “touched” several times per pipeline.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
rememberKeys()
Section titled “rememberKeys()”rememberKeys(
keys):void
Defined in: libs/runtime/src/change-log.ts:227
Remember which attribute types carry @key. Identity depends on this, and loadSchema only
restores types and attributes — so without persisting it, a reopened database could not tell
which attribute names an entity.
Parameters
Section titled “Parameters”readonly string[]
Returns
Section titled “Returns”void
since()
Section titled “since()”since(
cursor?,limit?): readonlyChangeRecord[]
Defined in: libs/runtime/src/change-log.ts:698
Everything after cursor, in commit order.
No gap handling, and that is safe rather than lazy: SQLite permits one writer at a time, so
write transactions commit serially and seq allocation order equals commit order. There is no
window where seq 6 is visible while seq 5 is still uncommitted.
Parameters
Section titled “Parameters”cursor?
Section titled “cursor?”number = 0
limit?
Section titled “limit?”number = 500
Returns
Section titled “Returns”readonly ChangeRecord[]
stateOf()
Section titled “stateOf()”stateOf(
id,rev):EntityState|undefined
Defined in: libs/runtime/src/change-log.ts:351
The state a revision carried, if it carried any.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”EntityState | undefined
vacuum()
Section titled “vacuum()”vacuum():
void
Defined in: libs/runtime/src/change-log.ts:803
Return freed pages to the filesystem. Not part of compact because VACUUM cannot run inside
a transaction, and because a caller may reasonably want the rows gone without paying for a
whole-file rewrite.
Returns
Section titled “Returns”void
winnerOf()
Section titled “winnerOf()”winnerOf(
id):Leaf|undefined
Defined in: libs/runtime/src/change-log.ts:335
The winning leaf, by ADR-003 D3’s total rule.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Leaf | undefined
TypeDBLite is an independent open-source project, built on TypeDB with thanks. It is not affiliated with, sponsored by, or endorsed by TypeDB Ltd. Released under the MPL-2.0 license.