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
use crateValue;
/// Metadata about a single column in a model's table schema.
///
/// Generated automatically by `#[derive(DeriveModel)]` and used by
/// [`QueryBuilder::create_table`] to generate DDL statements.
///
/// # Example
///
/// ```rust
/// use grorm::{DeriveModel, ColumnInfo, Model};
///
/// #[derive(Debug, DeriveModel)]
/// #[table = "users"]
/// struct User {
/// id: i64,
/// #[index]
/// name: String,
/// #[unique]
/// email: String,
/// age: i32,
/// }
///
/// let schema = User::table_schema();
/// assert_eq!(schema.len(), 4);
/// assert!(schema[0].is_primary_key);
/// assert!(schema[1].is_index);
/// assert!(schema[2].is_unique);
/// ```
/// Trait implemented by `#[derive(DeriveModel)]` for ORM model types.
///
/// Provides table metadata, column information, and row serialization/deserialization.
///
/// # Derivable
///
/// This trait is typically derived using `#[derive(DeriveModel)]`:
///
/// ```rust
/// use grorm::DeriveModel;
///
/// #[derive(Debug, DeriveModel)]
/// #[table = "users"]
/// struct User {
/// id: i64,
/// name: String,
/// email: String,
/// age: i32,
/// }
/// ```
///
/// # Attributes
///
/// | Attribute | Scope | Description |
/// |-----------|-------|-------------|
/// | `#[table = "name"]` | struct | Override table name (default: lowercase struct name + "s") |
/// | `#[primary_key = "col"]` | struct | Override primary key column (default: `id`) |
/// | `#[index]` | field | Create a regular index on this column |
/// | `#[unique]` | field | Create a unique constraint on this column |
/// | `#[unique_index = "name"]` | field | Group columns into a composite unique index |