| Crates.io | tor-metrics-datamodel |
| lib.rs | tor-metrics-datamodel |
| version | 1.2.1-rc2 |
| created_at | 2025-08-07 06:48:14.45196+00 |
| updated_at | 2026-01-12 10:17:49.780615+00 |
| description | Shared data model with entities and migrations |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1784759 |
| size | 794,630 |
The DataModel library provides a set of Rust structs that represent database table entities. These structs can be used to interact with the database in a type-safe and convenient way.
To use the DataModel library in your own Rust project, add the following dependency to your Cargo.toml file:
[dependencies]
data_model = { path = "/path/to/data_model" }
Then, import the library in your Rust code and use the provided structs to interact with the database:
use data_model::{BandwidthFile, BandwidthRecord, /* other entities */};
// Use the entities to interact with the database
let bandwidth_file = BandwidthFile::find(1).unwrap();
The DataModel library also provides a CLI for creating & running migrations.
cargo run -- generate MIGRATION_NAME
cargo run
cargo run -- up
cargo run -- up -n 10
cargo run -- down
cargo run -- down -n 10
cargo run -- fresh
cargo run -- refresh
cargo run -- reset
cargo run -- status