1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//! # Toql - A friendly and productive ORM
//!
//!
//! [Beginner Guide](https://roy-ganz.github.io/toql), [API documentation](https://docs.rs/toql/0.3/toql/)
//!
//! Toql is an ORM for async databases that features
//! - Translation between Rust structs and database tables.
//! - Can load and modify nested structs.
//! - A unique dead simple query language, suitable for web clients.
//! - Different table aliases from long and readable to tiny and fast.
//! - Prepared statements against SQL injection.
//! - Support for raw SQL for full database power.
//! - Support for role based access.
//! - Highly customizable through user defined parameters, query functions, field handlers, etc.
//! - Compile time safety for queries, fields and path names.
//! - No unsafe Rust code.
//! - Tested on real world scenario.
//!
//! It currently only supports **MySQL**. More are coming, promised :)
//!
//! ## Installation
//! Add this to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! toql = {version = "0.3", features = ["serde"]}
//! toql_mysql_async = "0.3"
//! ```
//!
//! ## Look And Feel
//!
//! Derive your structs:
//! ```rust, ignore
//! #[derive(Toql)]
//! #[toql(auto_key = true)]
//! struct Todo {
//!     #[toql(key)]
//!     id: u64,
//!     what: String,
//!
//!     #[toql(join())]
//!     user: User
//! }
//! ```
//!
//! And do stuff with them:
//! ```rust, ignore
//! let toql = ...
//! let todo = Todo{ ... };
//!
//! // Insert todo and update its generated id
//! toql.insert_one(&mut todo, paths!(top)).await?;
//!
//! // Compile time checked queries!
//! let q = query!(Todo, "*, user_id eq ?", &todo.user.id);
//!
//! // Typesafe loading
//! let user = toql.load_many(q).await?;
//! ```
//!
//!
//! ## Quick start
//! Toql has a [supporting crate](https://crates.io/crates/toql_rocket) to play well with [Rocket](https://crates.io/crates/rocket). Check out the [CRUD example](https://github.com/roy-ganz/todo_rotomy).
//!
//! ## Contribution
//! Comments, bug fixes and quality improvements are welcome.
//!
//! ## License
//! Toql is distributed under the terms of both the MIT license and the
//! Apache License (Version 2.0).

pub use toql_core::alias_format;
pub use toql_core::alias_translator;
pub use toql_core::error;
pub use toql_core::from_row;
pub use toql_core::identity;
pub use toql_core::key;
pub use toql_core::key_fields;
pub use toql_core::keyed;
pub use toql_core::map_key;
pub use toql_core::query;
pub use toql_core::result;
pub use toql_core::sql;
pub use toql_core::sql_arg;
pub use toql_core::sql_expr;
pub use toql_core::toql_api::fields;
pub use toql_core::toql_api::paths;

pub use toql_core::log_sql; // Export macro for derives
pub use toql_core::none_error;
pub use toql_core::ok_or_fail; // Export macro (TODO: check for removal) // Export macro for macros

pub use toql_core::backend;
pub use toql_core::field_handler;
pub use toql_core::join_handler;
pub use toql_core::predicate_handler;
pub use toql_core::query_fields;
pub use toql_core::query_parser;
pub use toql_core::query_path;
pub use toql_core::sql_builder;
pub use toql_core::table_mapper;
pub use toql_core::table_mapper_registry;
pub use toql_core::tree;
//pub use toql_core::update_field;
//pub use toql_core::insert_path;
pub use toql_core::join;
//pub use toql_core::try_join;

pub use toql_derive as derive;
pub use toql_fields_macro as fields_macro;
pub use toql_paths_macro as paths_macro;
pub use toql_query_macro as query_macro;
pub use toql_role_expr_macro as role_expr_macro;
pub use toql_sql_expr_macro as sql_expr_macro;

pub use toql_core::cache;
pub use toql_core::deserialize;
pub use toql_core::page;
pub use toql_core::page_counts;
pub use toql_core::parameter_map;
pub use toql_core::role_expr;
//pub use toql_core::role_expr_parser;
pub use toql_core::mock_db;
pub use toql_core::role_validator;

pub use toql_core::toql_api; // Export for derives
pub use toql_core::tracing; // Reexport for derive

#[cfg(feature = "serde")]
pub use toql_core::serde; // Reexport for derive

pub use toql_core::log_literal_sql;
pub use toql_core::row; // For unit tests

pub mod prelude;