Crates.io | elephantry |
lib.rs | elephantry |
version | 4.0.1 |
source | src |
created_at | 2020-05-14 09:52:22.156762 |
updated_at | 2024-03-18 22:03:45.544643 |
description | Object model manager for PostgreSQL |
homepage | https://elephantry.github.io |
repository | https://github.com/elephantry/elephantry |
max_upload_size | |
id | 241464 |
size | 393,748 |
When Rust meets PostgreSQL.
See quickstart and examples.
Elephantry is an OMM (object model manager) dedicated to PostgreSQL design to handle from simple to complex queries.
let database_url = std::env::var("DATABASE_URL")
.unwrap_or_else(|_| "postgres://localhost".to_string());
// Connect
let elephantry = elephantry::Pool::new(&database_url)?;
// Simple query
let rows = elephantry.execute("select id from entity")?;
for row in &rows {
let id: i32 = row.get("id");
println!("{id}");
}
// Define entity
#[derive(elephantry::Entity)]
#[elephantry(model = "Model", structure = "Structure")]
struct Entity {
#[elephantry(pk)]
id: u16,
deleted: bool,
}
// Read entities
let entity = elephantry.find_by_pk::<Model>(&elephantry::pk!(id))?;
let entities = elephantry.find_all::<Model>(None)?;
let entities = elephantry.find_where::<Model>("deleted = $1", &[&false], None)?;
// Write entities
elephantry.insert_one::<Model>(&entity)?;
elephantry.update_one::<Model>(&elephantry::pk!{id => entity.id}, &entity)?;
elephantry.delete_one::<Model>(&entity)?;
elephantry.delete_where::<Model>("deleted = $1", &[&true])?;
all-types
— enables all type features (see below);arbitrary
— add support for arbitrary
crate;config
— adds support for config
layered configuration system;inspect
— include the inspect
module to inspect a database structure;pg14
— enables postgresql 14 features (multirange and new
TargetSessionAttrs
);r2d2
— adds support for r2d2 generic
connection pool;rocket
— adds support for
rocket web framewok;serde
— adds support for de/serialization via serde.bit
— adds support for
bit type;
date
— adds support for
date type;
geo
— adds support for
geometric
type;
json
— adds support for
json type;
ltree
— adds support for
ltree types;
multirange
— adds support for
multirange type
(postgresql >= 14);
money
— adds support for
money type;
net
— adds support for
network
type;
numeric
— adds support for
numeric
type;
time
— adds support for
time type;
uuid
— adds support for
uuid type;
xml
— adds support for
xml type.
If you want to add your project here, please create a pull request.