Skip to content

Node Class API Reference

A node in the database. It has a base type, ID, and properties from base type (and it's parent type recursively).

Node class is designed to be instanced by an engine:

alice = engine.create_node("Person", "alice", "Alice", 43, "alice@email.com")

Attributes:

  • type_name (str) –

    Name of base NodeType.

  • id (str) –

    The unique identifier of node.

    Note

    id is designed to be persistent and unique across database, you can set in manually or with uuid. Changing ID of a node breaks its references.

    Tip

    Nodes are hashable and comparable by ID, so nodes with same ID is equal in == operator and will replace each other if added in the same engine.

  • values (dict[str, Any]) –

    A dictionary holding field values. Use set() and get() methods to use it.

    Tip

    Values can be accessed with node["field_name"] too.

  • type_ref (NodeType | None) –

    Reference to NodeType.

Methods:

  • get

    Returns value of a field in this node.

  • set

    Sets a field in this node.

Functions

get

get(field_name: str) -> Any

Returns value of a field in this node.

Parameters:

  • field_name (str) –

    Field name.

Returns:

  • Any

    Value.

set

set(field_name: str, value: Any) -> None

Sets a field in this node.

Parameters:

  • field_name (str) –

    Field name.

  • value (Any) –

    Value to set.

Subject To Change

Currently type of values can be invalid. This may be fixed in next versions.