16
16
17
17
## Overview
18
18
19
- [ GeekORM] [ docs-orm ] is a simple [ Object Relation Mapper] [ docs-orm ] for empowering your [ Rust] [ rust-lang ] development.
19
+ [ GeekORM] [ crates-io ] is a simple [ Object Relation Mapper] [ docs-orm ] for empowering your [ Rust] [ rust-lang ] development.
20
20
21
21
## ✨ Features
22
22
25
25
- Using ` GeekTable `
26
26
- Dynamically build queries
27
27
- ` Select ` , ` Create ` , ` Update ` , and ` Insert ` queries
28
- - Generate helper functions
29
- - Select ` select_by_primary_key() ` & ` select_by_{field}() `
30
- - New instance ` new `
28
+ - [ Extensive crate features] ( #-create-features )
29
+ - Field Attribute Helpers
30
+ - ` foreign_key ` : Set the foreign key for a join
31
+ - [ ` rand ` ] [ docs-rand ] : Generate random strings (set lenght, set prefix, set enviroment)
32
+ - [ ` hash ` or ` password ` ] [ docs-hash ] : Generate secure Hashes of passwords (set algorithm)
31
33
- Support for Backends
32
34
- [ ` libsql ` ] [ lib-libsql ] ([ Turso] [ web-turso ] )
33
35
- [ Documentation] [ docs ]
@@ -46,6 +48,56 @@ cargo add geekorm
46
48
cargo install --git https://github.com/42ByteLabs/geekorm
47
49
```
48
50
51
+ ## 🏃 Getting Started
52
+
53
+ Once you have installed ` geekorm ` , you can start using the derive macros like the following:
54
+
55
+ ``` rust
56
+ use geekorm :: prelude :: * ;
57
+ use geekorm :: {QueryOrder , PrimaryKeyInteger };
58
+
59
+ #[derive(Debug , Clone , GeekTable )]
60
+ struct Users {
61
+ id : PrimaryKeyInteger ,
62
+ username : String ,
63
+ email : String ,
64
+ age : i32 ,
65
+ postcode : Option <String >,
66
+ }
67
+
68
+ // Use the `create` method to build a CREATE TABLE query
69
+ let create_table = Users :: create (). build ()
70
+ . expect (" Failed to build create table query" );
71
+ println! (" Create Table Query: {}" , create_table );
72
+
73
+ // Use the `select` method to build a SELECT query along with different conditions
74
+ // and ordering
75
+ let select_user = Users :: select ()
76
+ . where_eq (" username" , " geekmasher" )
77
+ . and ()
78
+ . where_gt (" age" , 42 )
79
+ . order_by (" age" , QueryOrder :: Asc )
80
+ . limit (10 )
81
+ . build ()
82
+ . expect (" Failed to build query" );
83
+
84
+ ```
85
+
86
+ ### 🏄 Create Features
87
+
88
+ There are a number of opt-in features supported by GeekORM.
89
+ Features can be added either [ using ` cargo add geekorm -F all ` ] [ docs-cargo-add ] or added them directly in your ` Cargo.toml ` file.
90
+
91
+ - ` all ` : Enable all the major stable features
92
+ - [ ` new ` ] [ docs-new ] : Generate ` Table::new(...) ` functions
93
+ - [ ` helpers ` ] [ docs-helpers ] : Generate a number of helper functions
94
+ - Select ` Table::select_by_primary_key() `
95
+ - Select column ` Table::select_by_{field}() `
96
+ - [ ` rand ` ] [ docs-rand ] : Support Generating random strings
97
+ - [ ` hash ` ] [ docs-hash ] : Support Generating password hashes
98
+ - Backends
99
+ - ` libsql ` : Add LibSQL backend support
100
+
49
101
## 🧑🤝🧑 Maintainers / Contributors
50
102
51
103
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
@@ -87,6 +139,12 @@ Please refer to [MIT][license] for the full terms.
87
139
[ github-issues ] : https://github.com/42ByteLabs/geekorm/issues
88
140
[ crates ] : https://crates.io
89
141
[ docs-orm ] : https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping
142
+ [ docs-cargo-add ] : https://doc.rust-lang.org/cargo/commands/cargo-add.html#dependency-options
143
+
144
+ [ docs-new ] : https://docs.rs/geekorm-derive/latest/geekorm_derive/derive.GeekTable.html#generate-new-rows
145
+ [ docs-helpers ] : https://docs.rs/geekorm-derive/latest/geekorm_derive/derive.GeekTable.html#generated-helper-methods
146
+ [ docs-hash ] : https://docs.rs/geekorm-derive/latest/geekorm_derive/derive.GeekTable.html#generate-hash-for-storing-passwords
147
+ [ docs-rand ] : https://docs.rs/geekorm-derive/latest/geekorm_derive/derive.GeekTable.html#generate-random-data-for-column
90
148
91
149
[ lib-libsql ] : https://github.com/tursodatabase/libsql
92
150
[ web-turso ] : https://turso.tech/
0 commit comments