temporal97
API Reference

Writing

Add entries to the temporal log.

append(input)

Appends a single entry to the log. Returns a Delta describing what changed.

Throws if the cursor is not at the head of the log, or if the snapshot would go backwards.

const delta = graph.append({
  snapshot: 3,
  event: { type: "node-removed" }, // optional
  mutations: [
    { kind: "node", op: "delete", id: "b" },
  ],
});
// delta.nodes.removed → Set { "b" }

ingest(inputs)

Bulk-appends a pre-sorted array of entries. More efficient than repeated append() calls — it computes a single diff for the whole batch instead of one per entry.

Throws if entries are not in ascending snapshot order.

graph.ingest([
  {
    snapshot: 10,
    mutations: [
      { kind: "node", op: "set", id: "a", value: { label: "Alice" } },
    ],
  },
  {
    snapshot: 20,
    mutations: [
      { kind: "node", op: "set", id: "b", value: { label: "Bob" } },
      { kind: "edge", op: "set", id: "a->b", value: { source: "a", target: "b" } },
    ],
  },
]);

Use ingest() when loading historical data or replaying a stream of events.

On this page