Expand description
§Sqlorm
An ergonomic lightweight SQL framework for comfortable database operations.
§Overview
Sqlorm is a lightweight sql framework based on sqlx.
It provides macro-generated code for communicating with database, and it is designed to be performant and easy to use.
§Main features:
- Easy to use: Sqlorm generates all code for specific struct using
sqlorm::table
macro. - Type-safe (mostly): Since 90% of code is geneated at compile time, all types are checked at compile time.
- Performant: Sqlorm introduces a minimal overhead over sqlx (thanks to macros).
To get start, look at sqlorm::table
§Todo list:
- Generic, type-safe query builder for each entity.
- Support for postgres.
- Support for sqlite.
- Support for most common relations (belongs-to, has-many, has-one).
- Modular system for optional extended functionality (additional ways to query, etc).
- Partial update support ( a big one )
- Limit, offset support
- Improved filtering system. ( OR, AND )
- Renaming fields
- Soft delete support
- Transactions
- Order-by clauses
- Improved update, delete QueryBuilder. (e.g. User::insert())
- Cross-relations filters
- Add support for custom, user-defined selectable types
- Problems: When loading relations batch, we need to move all foreign filters from original query to batch query. For that we need to rebuild qb and executor //! e.g. User::query().with_posts().filter(Post::read_time.gt_(4))
Optional todos: -[ ] Compile-time entity<->schema type check
§Usage
To use this crate you must activate one of the following features (else the crate wont compile):
postgres
sqlite
Modules§
- driver
- prelude
- qb
- sqlx
- The async SQL toolkit for Rust, built with ❤️ by the LaunchBadge team.
Structs§
- Column
- Represents a database column in a type-safe way.
- Condition
- Represents a SQL condition fragment with its associated bound values.
- Delete
- HashMap
- A hash map implemented with quadratic probing and SIMD lookup.
- Join
Spec - Specification for joining a related table.
- Order
BySpec - QB
- Query builder for composing SELECT statements with optional joins and filters.
- SB
- Table
Info - Static information about a table used to build queries.
- Update
Enums§
- Join
Type - Join type for related tables.
Traits§
- Bind
Value - From
Aliased Row - Constructs a value from a database row where columns were projected with aliases.
- Generic
Executor - Executes a built query and returns typed results.
- Statement
Executor - Table
- Describes a database table and its metadata used by the query builder.
Functions§
- format_
alised_ col_ name - with_
quotes - Quote identifiers appropriately for the target database Both PostgreSQL and SQLite support double quotes for identifiers
Type Aliases§
- Connection
- Sqlorm Database Connection
- Driver
- Sqlorm Database Driver
- Pool
- Sqlorm Database Pool
- Row
- Sqlorm Database Row
Attribute Macros§
- async_
trait - table
- Transforms a struct into a database entity with ORM capabilities.