| Crates.io | armature-seaorm |
| lib.rs | armature-seaorm |
| version | 0.1.0 |
| created_at | 2025-12-27 03:14:27.015139+00 |
| updated_at | 2025-12-27 03:14:27.015139+00 |
| description | SeaORM database integration for the Armature framework |
| homepage | https://pegasusheavy.github.io/armature |
| repository | https://github.com/pegasusheavy/armature |
| max_upload_size | |
| id | 2006628 |
| size | 112,121 |
SeaORM integration for the Armature framework.
[dependencies]
armature-seaorm = "0.1"
use armature_seaorm::{Database, DbConn};
use entity::user;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let db = Database::connect("postgres://localhost/mydb").await?;
// Find by ID
let user = user::Entity::find_by_id(1).one(&db).await?;
// Find all
let users = user::Entity::find().all(&db).await?;
// Insert
let new_user = user::ActiveModel {
name: Set("Alice".to_owned()),
..Default::default()
};
let user = new_user.insert(&db).await?;
// Update
let mut user: user::ActiveModel = user.into();
user.name = Set("Bob".to_owned());
user.update(&db).await?;
// Delete
user::Entity::delete_by_id(1).exec(&db).await?;
Ok(())
}
use armature_seaorm::Paginator;
let paginator = user::Entity::find()
.paginate(&db, 10);
let page = paginator.fetch_page(0).await?;
let total = paginator.num_pages().await?;
MIT OR Apache-2.0