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
//! # Fabrique
//!
//! SQL-first, type-safe, ergonomic database toolkit for Rust.
//!
//! Fabrique provides a fluent API for defining models, querying
//! data, and generating test fixtures — built on SQL semantics
//! rather than hiding them.
//!
//! ## Core Features
//!
//! ### Models
//!
//! Define database models using the `#[derive(Model)]` macro. Models
//! automatically map to database tables and provide methods for CRUD
//! operations, soft deletes, and more. See the [`model`] module for detailed
//! documentation.
//!
//! ### Query Builder
//!
//! Build type-safe database queries with a fluent API. The query builder
//! provides methods for filtering, ordering, limiting results, and more. See
//! the [`query_builder`] module for details.
//!
//! ### Factories
//!
//! Generate test data easily with the `#[derive(Factory)]` macro. Factories
//! help you create model instances for testing without manually specifying
//! every field. See the [`factory`] module for more information.
//!
//! ## Quick Example
//!
//! ```rust
//! # extern crate fabrique;
//! # extern crate sqlx;
//! # extern crate tokio;
//! # extern crate uuid;
//! use fabrique::prelude::*;
//! # use uuid::Uuid;
//!
//! // Define a model
//! #[derive(Clone, Model, Factory)]
//! pub struct Product {
//! id: uuid::Uuid,
//! name: String,
//! price_cents: i32,
//! }
//!
//! # #[fabrique::doctest]
//! # async fn main(pool: Pool<sqlx::Sqlite>) -> Result<(), fabrique::Error> {
//! // Query the database
//! let expensive_products: Vec<Product> = Product::query()
//! .r#where(Product::PRICE_CENTS, ">=", 1000)
//! .get(&pool)
//! .await?;
//!
//! // Create a new record
//! let product = Product {
//! id: uuid::Uuid::new_v4(),
//! name: "Anvil 3000".to_string(),
//! price_cents: 9999,
//! };
//! product.create(&pool).await?;
//!
//! // Generate test data with factories
//! let test_product = Product::factory().create(&pool).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Getting Started
//!
//! To use Fabrique in your project, add it to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! fabrique = { version = "0.2", features = ["sqlite"] }
//!
//! [dev-dependencies]
//! fabrique = { version = "0.2", features = ["testing"] }
//! ```
//!
//! Then define your models and start querying. See the [`model`] module for a
//! comprehensive guide on model conventions and usage
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use fake;
/// Generates a seeded value for factory fields.
///
/// When the `testing` feature is enabled, this generates random test data
/// using the `fake` crate.
///
/// This function is used internally by the `#[derive(Factory)]` macro and
/// should not typically be called directly.
pub use __private;
pub use doctest;
pub use test;