Expand description
GeekORM is a simple and lightweight ORM for Rust. It is designed to be simple and easy to use.
This project is still in the early stages of development, and as such, it may not be suitable for all use cases.
§Features
- Simple and lightweight
- Uses derive macros for easy table creation
- Helper Functions to make things easy
- Automatic
new
function- feature:
new
- feature:
- Automatic
select_by_{field}
functions- feature:
helpers
- feature:
- Automatic
- Multi-Backends Support
- Query builder pattern for building SQL queries
- Only supports SQLite at the moment
§Example
Here is a simple example of how to use GeekORM:
use geekorm::prelude::*;
use geekorm::{QueryOrder, PrimaryKeyInteger};
#[derive(Debug, Clone, GeekTable)]
struct Users {
id: PrimaryKeyInteger,
username: String,
email: String,
age: i32,
postcode: Option<String>,
}
// Use the `create` method to build a CREATE TABLE query
let create_table = Users::create().build()
.expect("Failed to build create table query");
println!("Create Table Query: {}", create_table);
// Use the `select` method to build a SELECT query along with different conditions
// and ordering
let select_user = Users::select()
.where_eq("username", "geekmasher")
.and()
.where_gt("age", 20)
.order_by("age", QueryOrder::Asc)
.limit(10)
.build()
.expect("Failed to build query");
println!("Select Users Query: {}", select_user);
// Print the values that will be used in the query
// This is useful for passing values to a database driver or connection in the correct order
println!("Select Users Values: {:?}", select_user.values);
§Unsupported Features
If you are building a complex application, GeekORM may not be the best choice for you. GeekORM is designed to be simple and lightweight, and as such, it does not support some of the more advanced features that other ORMs may offer.
Here is a list of some of the features that GeekORM does not support (but may support in the future):
- Automatic Migrations
- Relationships (e.g. One-to-Many, Many-to-Many)
- Transactions
- Connection Pooling
If there are any features you would like to see in GeekORM, please open an issue on the GitHub repository.
Modules§
- GeekORM prelude
- Utils
Structs§
- A column in a table
- Column type options / properties
- A list of columns in a table
- Foreign Key Type
- Primary Key Type
- The built Query struct with the query and values to use
- The QueryBuilder is how you can build dynamically queries using the builder pattern.
- The Table struct for defining a table
- List of Values
Enums§
- A column type and its options / properties
- Error type for the crate
- Query Condition (EQ, NE, etc.)
- Query Order (ASC / DESC)
- Query Type (CREATE, SELECT, etc.)
- A value for a column
Constants§
- GeekORM Banner
- GeekORM Version
Type Aliases§
- Foreign Key as an Integer
- Primary Key as an Integer
- PrimaryKeyString (alias) is a Primary Key as a String type
Derive Macros§
- GeekTable Derive Macro Derive macro for
GeekTable
trait.