Skip to content

Commit 4ec3837

Browse files
authored
Merge pull request #60 from 42ByteLabs/readme-update
feat: Update README
2 parents e75d9dd + 2231699 commit 4ec3837

File tree

1 file changed

+62
-4
lines changed

1 file changed

+62
-4
lines changed

README.md

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
## Overview
1818

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.
2020

2121
## ✨ Features
2222

@@ -25,9 +25,11 @@
2525
- Using `GeekTable`
2626
- Dynamically build queries
2727
- `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)
3133
- Support for Backends
3234
- [`libsql`][lib-libsql] ([Turso][web-turso])
3335
- [Documentation][docs]
@@ -46,6 +48,56 @@ cargo add geekorm
4648
cargo install --git https://github.com/42ByteLabs/geekorm
4749
```
4850

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+
49101
## 🧑‍🤝‍🧑 Maintainers / Contributors
50102

51103
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
@@ -87,6 +139,12 @@ Please refer to [MIT][license] for the full terms.
87139
[github-issues]: https://github.com/42ByteLabs/geekorm/issues
88140
[crates]: https://crates.io
89141
[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
90148

91149
[lib-libsql]: https://github.com/tursodatabase/libsql
92150
[web-turso]: https://turso.tech/

0 commit comments

Comments
 (0)