Crates.io | tor-metrics-datamodel |
lib.rs | tor-metrics-datamodel |
version | 0.1.19-rc |
created_at | 2025-08-07 06:48:14.45196+00 |
updated_at | 2025-09-24 09:09:59.080543+00 |
description | Shared data model with entities and migrations |
homepage | |
repository | |
max_upload_size | |
id | 1784759 |
size | 672,542 |
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