Graph commands
31 commands. Each entry gives the invocation and an example, in the interface you pick; open the details for parameters, return shape and error codes.
apply_delete_policy
Apply a delete policy to bound graph facts.
db.graphs.apply_delete_policy(primitive: 'str', key: 'str', policy: 'str', *, space: 'Optional[str]' = None) -> 'Any'
Applies an explicit policy to every graph node bound to the given entity target: `cascade` deletes the bound nodes and their incident edges, `detach` keeps the nodes but removes their bindings, and `keep_dangling` preserves the bindings so traversal can report the target's status. The acknowledgement reports how many bound nodes the policy covered.
To see the complete help for this command, run:
help(db.graphs.apply_delete_policy)
Example
_ = db.graphs.create("kb")_ = db.graphs.add_node("kb", "ada", binding={"target": {"primitive": "kv", "space": "default", "key": "user:1"}})_ = db.graphs.apply_delete_policy("kv", "user:1", "cascade") # cascade removes the bound node and its incident edges.db.graphs.get_node("kb", "ada") is None
batch_write
Apply graph mutations atomically.
db.graphs.batch_write(graph: 'str', operations: 'list') -> 'Any'
Applies a list of graph operations - `upsert_node`, `delete_node`, `upsert_edge`, `delete_edge` - in one engine commit. Validation failures (bad ids, missing edge endpoints, frozen-ontology violations) reject the whole batch; nothing is partially applied. The response reports one positional item result per operation, all sharing the same commit receipt.
To see the complete help for this command, run:
help(db.graphs.batch_write)
Example
_ = db.graphs.create("g")_ = db.graphs.batch_write("g", [{"type": "upsert_node", "node_id": "a", "data": {"object_type": "person"}}, {"type": "upsert_node", "node_id": "b", "data": {"object_type": "person"}}, {"type": "upsert_edge", "src": "a", "edge_type": "knows", "dst": "b", "data": {}}]) # All operations land in one engine commit, or none do.db.graphs.meta("g").node_count
bindings
Find graph nodes bound to an entity.
db.graphs.bindings_for_entity(primitive: 'str', key: 'str', *, space: 'Optional[str]' = None, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Page'
Searches every graph in the selected branch and space for nodes whose entity binding matches the given target (primitive, space, key). This is the reverse index of node bindings: given an entity, find the graph facts attached to it. Results paginate by an opaque cursor.
To see the complete help for this command, run:
help(db.graphs.bindings_for_entity)
Example
_ = db.graphs.create("kb")_ = db.graphs.add_node("kb", "ada", binding={"target": {"primitive": "kv", "space": "default", "key": "user:1"}}) # Bind the node to a KV entity so retrieval can cross primitives.[h.node_id for h in db.graphs.bindings_for_entity("kv", "user:1")]
bulk_insert
Bulk-load nodes and edges in chunks.
strata graph bulk-insert
db.graphs.bulk_insert(graph: 'str', *, nodes: 'Optional[list]' = None, edges: 'Optional[list]' = None, chunk_size: 'Optional[int]' = None) -> 'Any'
Ingests a payload of nodes and edges in chunked commits: nodes first, then edges, so edges may reference nodes from the same payload. Node objects use the key `node_id`; edges use `src`, `edge_type`, `dst`, and optional `weight` (default 1.0) and `properties`. `chunk_size` bounds items per commit (default 512, clamped at 800). The acknowledgement reports inserted counts, the number of chunk commits, and the final chunk's commit receipt.
To see the complete help for this command, run:
strata graph bulk-insert --helphelp(db.graphs.bulk_insert)
Example
strata graph create gstrata command run --command-json '{"edges":[{"dst":"b","edge_type":"knows","src":"a"}],"graph":"g","nodes":[{"node_id":"a","object_type":"person"},{"node_id":"b","object_type":"person"}],"type":"graph_bulk_insert"}'strata graph meta g
_ = db.graphs.create("g")_ = db.graphs.bulk_insert("g", nodes=[{"node_id": "a", "object_type": "person"}, {"node_id": "b", "object_type": "person"}], edges=[{"src": "a", "edge_type": "knows", "dst": "b"}])db.graphs.meta("g").node_count
create
Create a named graph.
strata graph create
db.graphs.create(name: 'str') -> 'Any'
Creates an empty named graph in the selected space and returns its metadata, including node and edge counts (zero at creation) and the create commit coordinates. A database can hold many graphs; graph names are unique per branch and space. Creating a name that already exists fails with `already_exists.engine.graph`.
To see the complete help for this command, run:
strata graph create --helphelp(db.graphs.create)
Example
strata graph create socialstrata graph list
_ = db.graphs.create("social")db.graphs.list()
delete
Delete a graph and its visible data.
strata graph delete
db.graphs.delete(name: 'str') -> 'Any'
Deletes a named graph and every visible node, edge, binding, and ontology row it owns. Deleting a graph that does not exist is not an error: the acknowledgement reports `deleted: false` with a `not_found` effect. Earlier states remain readable through time travel on other commands.
To see the complete help for this command, run:
strata graph delete --helphelp(db.graphs.delete)
Example
strata graph create tempstrata graph delete tempstrata graph list
_ = db.graphs.create("temp")_ = db.graphs.delete("temp")db.graphs.list()
list
List graph names.
strata graph list
db.graphs.list(*, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'list'
Lists graph names in lexicographic order. Accepts an optional item limit (default 100), an exclusive name cursor for continuation, and an `as_of` timestamp to list the graphs visible at an earlier instant.
To see the complete help for this command, run:
strata graph list --helphelp(db.graphs.list)
Example
strata graph create socialstrata graph list
_ = db.graphs.create("social")db.graphs.list()
meta
Read graph metadata and counts.
strata graph meta
db.graphs.meta(name: 'str', *, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Any'
Reads a graph's metadata: live node and edge counts plus the create and last-update commit versions and timestamps. Reading a graph that does not exist returns no data rather than an error. Accepts `as_of` for time travel.
To see the complete help for this command, run:
strata graph meta --helphelp(db.graphs.meta)
Example
strata graph create socialstrata graph add-node social alicestrata graph add-node social bobstrata graph meta social
_ = db.graphs.create("social")_ = db.graphs.add_node("social", "alice")_ = db.graphs.add_node("social", "bob")db.graphs.meta("social").node_count
neighbors
List a node's neighbors.
strata graph neighbors
db.graphs.neighbors(graph: 'str', node_id: 'str', *, direction: 'str' = 'outgoing', edge_type: 'Optional[str]' = None, limit: 'Optional[int]' = None, cursor: 'Optional[Any]' = None, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Page'
Walks a node's edges and returns one hit per traversed edge. Direction is `outgoing`, `incoming`, or `both`; an optional edge-type filter restricts the walk. Each hit embeds both the traversed edge and the neighbor node in full, so a follow-up read is rarely needed. A missing node yields an empty page.
To see the complete help for this command, run:
strata graph neighbors --helphelp(db.graphs.neighbors)
Example
strata graph create socialstrata graph add-node social alicestrata graph add-node social bobstrata graph add-edge social alice knows bobstrata graph neighbors social alice --direction outgoing
_ = db.graphs.create("social")_ = db.graphs.add_node("social", "alice")_ = db.graphs.add_node("social", "bob")_ = db.graphs.add_edge("social", "alice", "knows", "bob")[n.node_id for n in db.graphs.neighbors("social", "alice", direction="outgoing")]
nodes_by_type
List nodes declaring an object type.
strata graph nodes-by-type
db.graphs.nodes_by_type(graph: 'str', object_type: 'str', *, limit: 'Optional[int]' = None, cursor: 'Optional[Any]' = None, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Page'
Lists the nodes that declare a given object type, in node-id order. The type index is maintained from each node's declared `object_type`, so this works whether the ontology is draft or frozen. Accepts a limit, an exclusive cursor, and `as_of` for time travel.
To see the complete help for this command, run:
strata graph nodes-by-type --helphelp(db.graphs.nodes_by_type)
Example
strata graph create gstrata graph add-node g a --type personstrata graph add-node g b --type personstrata graph nodes-by-type g person
_ = db.graphs.create("g")_ = db.graphs.add_node("g", "a", object_type="person")_ = db.graphs.add_node("g", "b", object_type="person")[n.node_id for n in db.graphs.nodes_by_type("g", "person")]
sample
Sample graph nodes.
strata graph sample
db.graphs.sample(graph: 'str', *, count: 'Optional[int]' = None) -> 'Sample'
Returns a deterministic representative sample of nodes from a graph: the total live node count and up to `count` nodes (default 10), evenly strided over the ordered node ids. Latest state only.
To see the complete help for this command, run:
strata graph sample --helphelp(db.graphs.sample)
Example
strata graph create gstrata graph add-node g astrata graph add-node g bstrata graph sample g
_ = db.graphs.create("g")_ = db.graphs.add_node("g", "a")_ = db.graphs.add_node("g", "b")db.graphs.sample("g").total_count
Analytics
analytics bfs
Run a bounded breadth-first traversal.
strata graph bfs
db.graphs.analytics.bfs(graph: 'str', start: 'str', *, direction: 'Optional[str]' = None, edge_types: 'Optional[list]' = None, max_depth: 'Optional[int]' = None, max_nodes: 'Optional[int]' = None, budget: 'Optional[dict]' = None, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Any'
Runs a breadth-first traversal from a start node over a consistent snapshot, bounded by `max_depth` (default 100) and `max_nodes` (default 10000). Returns visited node ids in traversal order, a depth per node, and the tree edges in discovery order. Direction defaults to `outgoing`; an optional edge-type list restricts every hop. The start node must exist (`not_found.engine.graph_node`).
To see the complete help for this command, run:
strata graph bfs --helphelp(db.graphs.analytics.bfs)
Example
strata graph create gstrata graph add-node g astrata graph add-node g bstrata graph add-node g cstrata graph add-edge g a knows bstrata graph add-edge g b knows cstrata graph bfs g a
_ = db.graphs.create("g")_ = db.graphs.add_node("g", "a")_ = db.graphs.add_node("g", "b")_ = db.graphs.add_node("g", "c")_ = db.graphs.add_edge("g", "a", "knows", "b")_ = db.graphs.add_edge("g", "b", "knows", "c")db.graphs.analytics.bfs("g", "a").visited
analytics cdlp
Detect communities via label propagation.
strata graph cdlp
db.graphs.analytics.cdlp(graph: 'str', *, direction: 'Optional[str]' = None, max_iterations: 'Optional[int]' = None, budget: 'Optional[dict]' = None, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Any'
Detects communities by label propagation over a consistent snapshot: every node repeatedly adopts the most common label among its neighbors until labels stabilize or the iteration bound (default 10) is reached. Every node maps to its community representative node id. Propagation direction defaults to `both`. Accepts an optional snapshot budget and `as_of` for time travel.
To see the complete help for this command, run:
strata graph cdlp --helphelp(db.graphs.analytics.cdlp)
Example
strata graph create gstrata graph add-node g astrata graph add-node g bstrata graph add-node g cstrata graph add-edge g a knows bstrata graph add-edge g b knows cstrata graph cdlp g
_ = db.graphs.create("g")_ = db.graphs.add_node("g", "a")_ = db.graphs.add_node("g", "b")_ = db.graphs.add_node("g", "c")_ = db.graphs.add_edge("g", "a", "knows", "b")_ = db.graphs.add_edge("g", "b", "knows", "c")sorted(db.graphs.analytics.cdlp("g").labels)
analytics lcc
Compute local clustering coefficients.
strata graph lcc
db.graphs.analytics.lcc(graph: 'str', *, budget: 'Optional[dict]' = None, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Any'
Computes the local clustering coefficient for every node over a consistent snapshot: the fraction of a node's neighbor pairs that are themselves connected. Nodes in fully-triangulated neighborhoods score 1.0. Accepts an optional snapshot budget and `as_of` for time travel.
To see the complete help for this command, run:
strata graph lcc --helphelp(db.graphs.analytics.lcc)
Example
strata graph create gstrata graph add-node g astrata graph add-node g bstrata graph add-node g cstrata graph add-edge g a knows bstrata graph add-edge g b knows cstrata graph lcc g
_ = db.graphs.create("g")_ = db.graphs.add_node("g", "a")_ = db.graphs.add_node("g", "b")_ = db.graphs.add_node("g", "c")_ = db.graphs.add_edge("g", "a", "knows", "b")_ = db.graphs.add_edge("g", "b", "knows", "c")sorted(db.graphs.analytics.lcc("g").coefficients)
analytics pagerank
Compute PageRank importance scores.
strata graph pagerank
db.graphs.analytics.pagerank(graph: 'str', *, damping: 'Optional[float]' = None, max_iterations: 'Optional[int]' = None, tolerance: 'Optional[float]' = None, personalization: 'Optional[dict]' = None, budget: 'Optional[dict]' = None, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Any'
Computes PageRank over a consistent snapshot. Tunable damping (default 0.85), iteration bound (default 20), and convergence tolerance (default 1e-6); the response reports how many iterations actually ran. Optional personalization seeds steer both teleport and dangling mass toward weighted nodes, and the response flags `personalized: true`. Results are deterministic for a fixed graph state. Accepts an optional snapshot budget and `as_of` for time travel.
To see the complete help for this command, run:
strata graph pagerank --helphelp(db.graphs.analytics.pagerank)
Example
strata graph create gstrata graph add-node g astrata graph add-node g bstrata graph add-node g cstrata graph add-edge g a knows bstrata graph add-edge g b knows cstrata graph pagerank g
_ = db.graphs.create("g")_ = db.graphs.add_node("g", "a")_ = db.graphs.add_node("g", "b")_ = db.graphs.add_node("g", "c")_ = db.graphs.add_edge("g", "a", "knows", "b")_ = db.graphs.add_edge("g", "b", "knows", "c")sorted(db.graphs.analytics.pagerank("g").ranks)
analytics sssp
Compute shortest-path distances from a source.
strata graph sssp
db.graphs.analytics.sssp(graph: 'str', source: 'str', *, direction: 'Optional[str]' = None, budget: 'Optional[dict]' = None, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Any'
Computes weighted shortest-path distances from a source node over a consistent snapshot. Edge weights (default 1.0) accumulate along paths; unreachable nodes are omitted from the result. Direction defaults to `outgoing`. The source node must exist (`not_found.engine.graph_node`). Accepts an optional snapshot budget and `as_of` for time travel.
To see the complete help for this command, run:
strata graph sssp --helphelp(db.graphs.analytics.sssp)
Example
strata graph create gstrata graph add-node g astrata graph add-node g bstrata graph add-node g cstrata graph add-edge g a knows bstrata graph add-edge g b knows cstrata graph sssp g a
_ = db.graphs.create("g")_ = db.graphs.add_node("g", "a")_ = db.graphs.add_node("g", "b")_ = db.graphs.add_node("g", "c")_ = db.graphs.add_edge("g", "a", "knows", "b")_ = db.graphs.add_edge("g", "b", "knows", "c")sorted(db.graphs.analytics.sssp("g", "a").distances)
analytics wcc
Compute weakly connected components.
strata graph wcc
db.graphs.analytics.wcc(graph: 'str', *, budget: 'Optional[dict]' = None, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Any'
Computes weakly connected components over a consistent snapshot of the graph, ignoring edge direction. Every node maps to its component representative - the smallest node id in its component - and the response carries the distinct component count. Accepts an optional snapshot budget and `as_of` for time travel.
To see the complete help for this command, run:
strata graph wcc --helphelp(db.graphs.analytics.wcc)
Example
strata graph create gstrata graph add-node g astrata graph add-node g bstrata graph add-node g cstrata graph add-edge g a knows bstrata graph add-edge g b knows cstrata graph wcc g
_ = db.graphs.create("g")_ = db.graphs.add_node("g", "a")_ = db.graphs.add_node("g", "b")_ = db.graphs.add_node("g", "c")_ = db.graphs.add_edge("g", "a", "knows", "b")_ = db.graphs.add_edge("g", "b", "knows", "c")db.graphs.analytics.wcc("g").component_count
Edges
edge add
Add or replace a graph edge.
strata graph add-edge
db.graphs.add_edge(graph: 'str', src: 'str', edge_type: 'str', dst: 'str', *, weight: 'Optional[float]' = None, properties: 'Optional[dict]' = None) -> 'Any'
Adds a directed edge `src -[edge_type]-> dst` or replaces it if the same triple already exists. Both endpoints must already exist; writing an edge to a missing node fails with `invalid_argument.engine.graph_edge_endpoint`. Weight defaults to 1.0 and must not be negative. Once the graph's ontology is frozen, the edge type and its endpoint object types are validated against the declared link types.
To see the complete help for this command, run:
strata graph add-edge --helphelp(db.graphs.add_edge)
Example
strata graph create socialstrata graph add-node social alicestrata graph add-node social bobstrata graph add-edge social alice knows bobstrata graph get-edge social alice knows bob
_ = db.graphs.create("social")_ = db.graphs.add_node("social", "alice")_ = db.graphs.add_node("social", "bob")_ = db.graphs.add_edge("social", "alice", "knows", "bob")db.graphs.get_edge("social", "alice", "knows", "bob").edge_type
edge get
Read one graph edge.
strata graph get-edge
db.graphs.get_edge(graph: 'str', src: 'str', edge_type: 'str', dst: 'str', *, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Any'
Reads one edge by its `(src, edge_type, dst)` triple, returning its weight, properties, and last-write commit coordinates. A missing edge reads back as no data. Accepts `as_of` for time travel.
To see the complete help for this command, run:
strata graph get-edge --helphelp(db.graphs.get_edge)
Example
strata graph create socialstrata graph add-node social alicestrata graph add-node social bobstrata graph add-edge social alice knows bobstrata graph get-edge social alice knows bobstrata graph get-edge social alice knows absent
_ = db.graphs.create("social")_ = db.graphs.add_node("social", "alice")_ = db.graphs.add_node("social", "bob")_ = db.graphs.add_edge("social", "alice", "knows", "bob")db.graphs.get_edge("social", "alice", "knows", "bob").edge_typedb.graphs.get_edge("social", "alice", "knows", "absent") is None
edge remove
Remove a graph edge.
strata graph remove-edge
db.graphs.remove_edge(graph: 'str', src: 'str', edge_type: 'str', dst: 'str') -> 'Any'
Removes one directed edge by its `(src, edge_type, dst)` triple. The endpoints are untouched. Removing an edge that does not exist is not an error: the acknowledgement reports `deleted: false`.
To see the complete help for this command, run:
strata graph remove-edge --helphelp(db.graphs.remove_edge)
Example
strata graph create socialstrata graph add-node social alicestrata graph add-node social bobstrata graph add-edge social alice knows bobstrata graph remove-edge social alice knows bobstrata graph get-edge social alice knows bob
_ = db.graphs.create("social")_ = db.graphs.add_node("social", "alice")_ = db.graphs.add_node("social", "bob")_ = db.graphs.add_edge("social", "alice", "knows", "bob")_ = db.graphs.remove_edge("social", "alice", "knows", "bob")db.graphs.get_edge("social", "alice", "knows", "bob") is None
Nodes
node add
Add or replace a graph node.
strata graph add-node
db.graphs.add_node(graph: 'str', node_id: 'str', *, properties: 'Optional[dict]' = None, object_type: 'Optional[str]' = None, binding: 'Optional[dict]' = None) -> 'Any'
Adds a node to a graph or replaces it if the node id already exists. A node carries optional JSON properties, an optional declared object type (validated once the graph's ontology is frozen), and an optional entity binding that links the node to a row in another primitive. Cross-branch bindings are rejected.
To see the complete help for this command, run:
strata graph add-node --helphelp(db.graphs.add_node)
Example
strata graph create socialstrata graph add-node social alice --type person --properties {"age":30}strata graph get-node social alice
_ = db.graphs.create("social")_ = db.graphs.add_node("social", "alice", properties={"age": 30}, object_type="person")db.graphs.get_node("social", "alice").properties
node get
Read one graph node.
strata graph get-node
db.graphs.get_node(graph: 'str', node_id: 'str', *, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Any'
Reads one node by id, returning its properties, declared object type, entity binding, and last-write commit coordinates. A removed or never-written node reads back as no data. Accepts `as_of` for time travel.
To see the complete help for this command, run:
strata graph get-node --helphelp(db.graphs.get_node)
Example
strata graph create socialstrata graph add-node social alice --type person --properties {"age":30}strata graph get-node social alicestrata graph get-node social absent
_ = db.graphs.create("social")_ = db.graphs.add_node("social", "alice", properties={"age": 30}, object_type="person")db.graphs.get_node("social", "alice").propertiesdb.graphs.get_node("social", "absent") is None
node list
List graph nodes.
strata graph list-nodes
db.graphs.list_nodes(graph: 'str', *, limit: 'Optional[int]' = None, cursor: 'Optional[Any]' = None, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None, prefix: 'Optional[str]' = None) -> 'Page'
Lists a graph's nodes in node-id order. Accepts an optional id prefix filter, an item limit (default 100), an exclusive cursor, and `as_of` for time travel. Each item carries the full node payload: properties, declared type, binding, and commit coordinates.
To see the complete help for this command, run:
strata graph list-nodes --helphelp(db.graphs.list_nodes)
Example
strata graph create socialstrata graph add-node social alicestrata graph add-node social bobstrata graph list-nodes social
_ = db.graphs.create("social")_ = db.graphs.add_node("social", "alice")_ = db.graphs.add_node("social", "bob")[n.node_id for n in db.graphs.list_nodes("social")]
node remove
Remove a graph node and its edges.
strata graph remove-node
db.graphs.remove_node(graph: 'str', node_id: 'str') -> 'Any'
Removes a node and every edge incident to it in one commit. Removing a node that does not exist is not an error: the acknowledgement reports `deleted: false`.
To see the complete help for this command, run:
strata graph remove-node --helphelp(db.graphs.remove_node)
Example
strata graph create socialstrata graph add-node social alicestrata graph remove-node social alicestrata graph get-node social alice
_ = db.graphs.create("social")_ = db.graphs.add_node("social", "alice")_ = db.graphs.remove_node("social", "alice")db.graphs.get_node("social", "alice") is None
Ontology
ontology define_link_type
Define a graph link type.
strata graph ontology define-link-type
db.graphs.ontology.define_link_type(graph: 'str', name: 'str', source: 'str', target: 'str', *, cardinality: 'Optional[str]' = None, properties: 'Optional[dict]' = None) -> 'Any'
Declares a link type in the graph's ontology: a name, its source and target object types, an optional cardinality hint (for example `many-to-one`), and property definitions. Source and target must name declared object types by the time the ontology is frozen. After freezing, this command fails with `failed_precondition.engine.graph_ontology_frozen`.
To see the complete help for this command, run:
strata graph ontology define-link-type --helphelp(db.graphs.ontology.define_link_type)
Example
strata graph create gstrata graph ontology define-object-type g personstrata graph ontology define-link-type g knows person personstrata graph ontology get g
_ = db.graphs.create("g")_ = db.graphs.ontology.define_object_type("g", "person")_ = db.graphs.ontology.define_link_type("g", "knows", "person", "person")[l.name for l in db.graphs.ontology.get("g").link_types]
ontology define_object_type
Define a graph object type.
strata graph ontology define-object-type
db.graphs.ontology.define_object_type(graph: 'str', name: 'str', *, properties: 'Optional[dict]' = None) -> 'Any'
Declares an object type in the graph's ontology: a name plus property definitions (`value_type`, `required`). While the ontology is a draft, redefining a type replaces it freely. After `graph.ontology.freeze`, the ontology is immutable and this command fails with `failed_precondition.engine.graph_ontology_frozen`.
To see the complete help for this command, run:
strata graph ontology define-object-type --helphelp(db.graphs.ontology.define_object_type)
Example
strata graph create gstrata graph ontology define-object-type g personstrata graph ontology summary g
_ = db.graphs.create("g")_ = db.graphs.ontology.define_object_type("g", "person")[o.name for o in db.graphs.ontology.summary("g").object_types]
ontology delete_link_type
Delete a draft link type.
strata graph ontology delete-link-type
db.graphs.ontology.delete_link_type(graph: 'str', name: 'str') -> 'Any'
Removes a link type from the graph's draft ontology. Deleting a type that was never declared is not an error: the acknowledgement reports `deleted: false`. Once the ontology is frozen this command fails with `failed_precondition.engine.graph_ontology_frozen`.
To see the complete help for this command, run:
strata graph ontology delete-link-type --helphelp(db.graphs.ontology.delete_link_type)
Example
strata graph create gstrata graph ontology define-object-type g personstrata graph ontology define-link-type g knows person personstrata graph ontology delete-link-type g knows
_ = db.graphs.create("g")_ = db.graphs.ontology.define_object_type("g", "person")_ = db.graphs.ontology.define_link_type("g", "knows", "person", "person")_ = db.graphs.ontology.delete_link_type("g", "knows")
ontology delete_object_type
Delete a draft object type.
strata graph ontology delete-object-type
db.graphs.ontology.delete_object_type(graph: 'str', name: 'str') -> 'Any'
Removes an object type from the graph's draft ontology. Deleting a type that was never declared is not an error: the acknowledgement reports `deleted: false`. Once the ontology is frozen this command fails with `failed_precondition.engine.graph_ontology_frozen`.
To see the complete help for this command, run:
strata graph ontology delete-object-type --helphelp(db.graphs.ontology.delete_object_type)
Example
strata graph create gstrata graph ontology define-object-type g personstrata graph ontology define-object-type g companystrata graph ontology delete-object-type g companystrata graph ontology summary g
_ = db.graphs.create("g")_ = db.graphs.ontology.define_object_type("g", "person")_ = db.graphs.ontology.define_object_type("g", "company")_ = db.graphs.ontology.delete_object_type("g", "company")[o.name for o in db.graphs.ontology.summary("g").object_types]
ontology freeze
Freeze the graph ontology.
strata graph ontology freeze
db.graphs.ontology.freeze(graph: 'str') -> 'Any'
Validates the draft ontology and freezes it. Validation requires at least one declared type and rejects link types whose source or target reference undeclared object types (`failed_precondition.engine.graph_ontology_freeze`). After freezing, writes enforce declared node object types, required properties, and link-type endpoint rules; the ontology itself can no longer change (`failed_precondition.engine.graph_ontology_frozen`).
To see the complete help for this command, run:
strata graph ontology freeze --helphelp(db.graphs.ontology.freeze)
Example
strata graph create gstrata graph ontology define-object-type g personstrata graph ontology freeze gstrata graph ontology get g
_ = db.graphs.create("g")_ = db.graphs.ontology.define_object_type("g", "person")_ = db.graphs.ontology.freeze("g")db.graphs.ontology.get("g").status
ontology get
Read the graph ontology.
strata graph ontology get
db.graphs.ontology.get(graph: 'str', *, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Any'
Reads the graph's ontology: its status (`draft` or `frozen`) plus every declared object type and link type with their property definitions. Returns no data before any type has been declared. Accepts `as_of` for time travel.
To see the complete help for this command, run:
strata graph ontology get --helphelp(db.graphs.ontology.get)
Example
strata graph create gstrata graph ontology define-object-type g personstrata graph ontology get g
_ = db.graphs.create("g")_ = db.graphs.ontology.define_object_type("g", "person")db.graphs.ontology.get("g").status
ontology summary
Read the ontology with usage counts.
strata graph ontology summary
db.graphs.ontology.summary(graph: 'str', *, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Any'
Reads the graph's ontology annotated with per-type usage: a node count for each object type and an edge count for each link type. Returns no data before any type has been declared. Accepts `as_of` for time travel.
To see the complete help for this command, run:
strata graph ontology summary --helphelp(db.graphs.ontology.summary)
Example
strata graph create gstrata graph ontology define-object-type g personstrata graph ontology summary g
_ = db.graphs.create("g")_ = db.graphs.ontology.define_object_type("g", "person")[o.name for o in db.graphs.ontology.summary("g").object_types]