GeekORM Derive
The geekorm_derive crate is for all pre-processing derive macros used by geekorm at build time.
Default Features
Generate Query Methods
By default, the following methods are generated for the struct:
create(): Create Queryselect(): Select Queryall(): Select all rows in a tableinsert(): Insert Queryupdate(): Update Querycount(): Count the number of rows
These are all defined by the geekorm_core::QueryBuilderTrait trait.
use *;
// Create a new table query
let create = query_create.build
.expect;
// Select data from the table
let select = query_select
.where_eq
.build
.expect;
// Create a default User
let mut user = default;
// Insert data
let insert = query_insert;
// Update query
user.name = Stringfrom;
let update = query_update;
Feature - Automatic New Struct Function
When the new feature is enabled, the following methods are generated for the struct:
PrimaryKey<T>fields are not generatedOption<T>fields are not generated
use *;
let user = new;
Feature - Generated Helper Methods
When the helpers feature is enabled, the following helper methods are generated for the struct:
Note: This is a very experimental feature and might change in the future.
use *;
// Select by column helper function
let user = query_select_by_name;
# assert_eq!;
let user = query_select_by_age;
# assert_eq!;
let user = query_select_by_occupation;
# assert_eq!;
Feature - Generate Random Data for Column
When using the rand feature, you can automatically generate random strings and use
#
#
rand attributes:
rand: Sets the String field as a randomly generated valuerand_length: Sets the length of the randomly generated string- Default:
32
- Default:
rand_prefix: Sets a prefix to the randomly generated string- Default: None
Feature - Generate Hashs for storing passwords
When using the hash feature, you can automatically hash passwords to make sure they are stored securely.
#
#
hash attributes:
hashorpassword: Sets the String field as a hashable valuehash_algorithm: Set the algorithm to use- Default:
Pbkdf2
- Default: