pub struct DataModel {
pub id: Uuid,
pub name: String,
pub description: Option<String>,
pub git_directory_path: String,
pub tables: Vec<Table>,
pub relationships: Vec<Relationship>,
pub control_file_path: String,
pub diagram_file_path: Option<String>,
pub is_subfolder: bool,
pub parent_git_directory: Option<String>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
Data model representing a complete data model with tables and relationships
A DataModel is a container for a collection of tables and their relationships.
It represents a workspace or domain within a larger data modeling system.
§Example
use data_modelling_sdk::models::DataModel;
let model = DataModel::new(
"MyModel".to_string(),
"/path/to/git".to_string(),
"control.yaml".to_string(),
);Fields§
§id: UuidUnique identifier for the model (UUIDv5 based on name and path)
name: StringModel name
description: Option<String>Optional description of the model
git_directory_path: StringPath to the Git repository directory
tables: Vec<Table>Tables in this model
relationships: Vec<Relationship>Relationships between tables
control_file_path: StringPath to the control file (relationships.yaml)
diagram_file_path: Option<String>Path to diagram file if applicable
is_subfolder: boolWhether this model is in a subfolder
parent_git_directory: Option<String>Parent Git directory if this is a subfolder
created_at: DateTime<Utc>Creation timestamp
updated_at: DateTime<Utc>Last update timestamp
Implementations§
Source§impl DataModel
impl DataModel
Sourcepub fn new(
name: String,
git_directory_path: String,
control_file_path: String,
) -> Self
pub fn new( name: String, git_directory_path: String, control_file_path: String, ) -> Self
Create a new data model with the given name and paths
§Arguments
name- The model namegit_directory_path- Path to the Git repository directorycontrol_file_path- Path to the control file (typically “relationships.yaml”)
§Returns
A new DataModel instance with a UUIDv5 ID (deterministic based on name and path)
and current timestamps.
§Example
use data_modelling_sdk::models::DataModel;
let model = DataModel::new(
"MyModel".to_string(),
"/workspace/models".to_string(),
"relationships.yaml".to_string(),
);Sourcepub fn get_table_by_id(&self, table_id: Uuid) -> Option<&Table>
pub fn get_table_by_id(&self, table_id: Uuid) -> Option<&Table>
Sourcepub fn get_table_by_id_mut(&mut self, table_id: Uuid) -> Option<&mut Table>
pub fn get_table_by_id_mut(&mut self, table_id: Uuid) -> Option<&mut Table>
Sourcepub fn get_table_by_name(&self, name: &str) -> Option<&Table>
pub fn get_table_by_name(&self, name: &str) -> Option<&Table>
Sourcepub fn get_table_by_unique_key(
&self,
database_type: Option<&str>,
name: &str,
catalog_name: Option<&str>,
schema_name: Option<&str>,
) -> Option<&Table>
pub fn get_table_by_unique_key( &self, database_type: Option<&str>, name: &str, catalog_name: Option<&str>, schema_name: Option<&str>, ) -> Option<&Table>
Get a table by its unique key (database_type, name, catalog, schema)
§Arguments
database_type- Optional database typename- Table namecatalog_name- Optional catalog nameschema_name- Optional schema name
§Returns
A reference to the table if found, None otherwise.
§Example
// Find table in specific schema
let table = model.get_table_by_unique_key(
Some("PostgreSQL"),
"users",
Some("mydb"),
Some("public"),
);Sourcepub fn get_relationships_for_table(&self, table_id: Uuid) -> Vec<&Relationship>
pub fn get_relationships_for_table(&self, table_id: Uuid) -> Vec<&Relationship>
Get all relationships involving a specific table
§Arguments
table_id- The UUID of the table
§Returns
A vector of references to relationships where the table is either the source or target.
§Example
// Get all relationships for a table
let relationships = model.get_relationships_for_table(table_id);