Utilities for interacting with the Yuneta TreeDB — the
schema-driven graph database built on top of timeranger2. See the
Timeranger2 API and the
TreeDB crash course for the
underlying semantics.
Available helpers¶
import {
treedb_hook_data_size,
treedb_decoder_fkey,
treedb_encoder_fkey,
treedb_decoder_hook,
treedb_get_field_desc,
template_get_field_desc,
create_template_record,
} from "@yuneta/gobj-js";treedb_hook_data_size(value)¶
Counts the items that a hook field references.
treedb_decoder_fkey(col, fkey)¶
Reads a foreign-key reference, and gives its topic, its identifier and its hook.
treedb_encoder_fkey(col, fkey)¶
Builds the canonical form of a foreign-key reference, "topic^id^hook".
treedb_decoder_hook(col, hook)¶
Reads a hook reference.
treedb_get_field_desc(col)¶
Builds the descriptor of a field from the definition of a column.
template_get_field_desc(key, value)¶
Builds the descriptor of a field from one entry of a template.
create_template_record(template, kw)¶
Builds a new record from the definition of a template.
Fkey format¶
TreeDB references children from parents via hooks (in-memory only)
and children point back to parents via fkeys (persisted). An fkey
value is a string with three ^-separated fields:
topic^parent_id^hook_nameFor example, a user record under the administration department
can have:
departments^administration^usersmeaning “my parent is in topic departments, with primary key
administration, and I belong to its users hook.”
The treedb_encoder_fkey / treedb_decoder_fkey helpers hide this
encoding so application code rarely has to look at the raw string.