pub struct DoltGraph {
pub repo_path: PathBuf,
}Expand description
Wrapper around a Dolt repository that stores graph data.
The DoltGraph type encapsulates a path to a Dolt repo and provides high‑level
operations such as initializing the repo, committing changes, creating tables, and
inserting nodes expressed as JSON objects.
§Architectural Rationale
Dolt offers a Git‑like version‑controlled SQL database, which aligns well with CHORUS’s need for an immutable, query‑able history of graph mutations. By wrapping Dolt commands in this struct we isolate the rest of the codebase from the command‑line interface, making the graph layer portable and easier to test.
Fields§
§repo_path: PathBufFilesystem path to the root of the Dolt repository.
Implementations§
Source§impl DoltGraph
impl DoltGraph
Sourcepub fn init(path: &Path) -> Result<Self, GraphError>
pub fn init(path: &Path) -> Result<Self, GraphError>
Initialise (or open) a Dolt repository at the given path.
If the directory does not already contain a .dolt sub‑directory, the function runs
dolt init to create a new repository. Errors from the underlying command are wrapped in
GraphError::CommandFailed.
Sourcepub fn commit(&self, message: &str) -> Result<(), GraphError>
pub fn commit(&self, message: &str) -> Result<(), GraphError>
Stage all changes and commit them with the provided message.
The method first runs dolt add -A to stage modifications, then dolt commit -m.
Any failure in these steps propagates as a GraphError.
Sourcepub fn create_table(
&self,
table_name: &str,
schema: &str,
) -> Result<(), GraphError>
pub fn create_table( &self, table_name: &str, schema: &str, ) -> Result<(), GraphError>
Create a SQL table within the Dolt repository.
schema should be a comma‑separated column definition list (e.g., "id INT PRIMARY KEY, name TEXT").
If the table already exists, the function treats it as a no‑op and returns Ok(()).
Sourcepub fn insert_node(&self, table: &str, data: Value) -> Result<(), GraphError>
pub fn insert_node(&self, table: &str, data: Value) -> Result<(), GraphError>
Insert a node represented by a JSON object into the specified table.
The JSON data must be an object where keys correspond to column names. Supported value
types are strings, numbers, booleans, and null. Complex JSON structures are rejected because
they cannot be directly mapped to SQL scalar columns.