Expand description
che-orm — экспериментальная типизированная ORM для Rust.
Runtime сейчас ориентирован на SQLite: Database предоставляет async
pool и high-level CRUD/query facade, а Model derive генерирует metadata,
row decoding и insert values. SQL можно также использовать отдельно через
SqlCompiler.
Основной рабочий сценарий:
ⓘ
use che_orm::{Database, Model};
let database = Database::connect_in_memory()?;
database.create_table::<User>().await?;
let user = database
.create::<User>()
.set(User::NAME, "Alice")
.execute()
.await?;
let loaded = database.get::<User>(user.id).await?;
assert!(loaded.is_some());Fixed string choices use DbEnum. It owns the JSON and database value,
so a variant has one canonical representation everywhere:
ⓘ
#[derive(Debug, Clone, Copy, DbEnum)]
enum TaskStatus {
Draft,
#[db_enum(rename = "in_progress")]
InProgress,
}Do not derive serde::Serialize or serde::Deserialize for a DbEnum;
the derive generates both implementations.
Re-exports§
pub use rusqlite;pub use serde;pub use serde_json;pub use time;
Structs§
- AppRegistry
- Registry that combines schemas from multiple application modules.
- Assignment
- Belongs
To - A typed forward foreign-key relation from one model to another.
- Column
Ref - Column
Schema - Metadata for one table column.
- Compiled
Query - SQL text and ordered bound parameters.
- Compiled
Schema - Table DDL plus separately executable indexes.
- Create
Builder - High-level insert builder. The executed result is the complete inserted model.
- Create
Table Ast - AST node for a
CREATE TABLEstatement. - Create
Table Query - Builder for a model’s
CREATE TABLEstatement. - Database
- Async SQLite database backed by a
deadpool-sqliteconnection pool. - Database
Query - High-level typed select builder bound to a database.
- Delete
Ast - Delete
Query - Execute
Result - Result metadata returned by an executed mutation or DDL statement.
- Foreign
Key - Foreign key metadata attached to a column.
- HasMany
- A typed reverse foreign-key relation from one model to many related models.
- Insert
Ast - Insert
Query - Insert
Value - JoinAst
- Joined
Field - Loaded
- A materialized model and a tuple of preloaded relations.
- Loaded
Many - One reverse relation inside a materialized relation tuple.
- Loaded
One - Model
Field - A typed reference to one model column.
- Multi
Prefetch Related Query - Query which materializes two reverse relations in one typed result.
- Multi
Select Related Query - Nested
Prefetch Plan - Nested
Prefetch Query - OrderBy
- Postgres
Dialect - Prefetch
Related Query - Query which materializes a model together with its reverse relation.
- Schema
Set - A collection of model schemas exported as one Atlas-compatible SQL schema.
- Select
Ast - Select
Query - Select
Related Query - Query which materializes a model together with one related model.
- Serializer
Field - SqlCompiler
- Sqlite
Dialect - Table
Ref - Table
Schema - Complete model table metadata used for DDL generation.
- Update
Ast - Update
Builder - High-level update builder scoped to one model primary key.
- Update
Query - Validation
Errors - With
Many - A model and its eagerly loaded reverse relation.
- WithOne
- A model and its eagerly loaded
belongs_torelation. - With
Optional One
Enums§
- Column
Type - SQL column types supported by the schema compiler.
- Compare
Op - Database
Value - Values bound to SQL placeholders.
- Expr
- Boolean and comparison expression tree used by query builders.
- Join
Type - Order
Direction - OrmError
- Errors returned by the SQLite pool and ORM runtime.
- Patch
Field - A JSON patch value.
Missingmeans that the property was not sent;Value(None)represents an explicit JSON null. - Query
Ast - Query
Build Error - Errors detected while finalizing a query builder.
- Schema
Error - Errors found in model-generated schema metadata.
- Validated
Write - Write
Mode
Traits§
- AppConfig
- Application-level model registration, similar to a Django app config.
- Column
Type Of - Maps a Rust field type to a SQL column type.
- DbEnum
- A string-backed enum that can be stored in a database column.
- Model
- Trait implemented by
#[derive(Model)]for ORM models. - Model
Serializer - Converts a materialized ORM model into an API representation.
- Model
Write Serializer - Prefetch
Relation - Query
Value - Relation
Source - Identifies the actual foreign-key column behind a serializer relation.
- SqlDialect