| Crates.io | bottle-orm-macro |
| lib.rs | bottle-orm-macro |
| version | 0.4.3 |
| created_at | 2026-01-18 20:20:32.211142+00 |
| updated_at | 2026-01-24 00:09:54.672175+00 |
| description | Procedural macros for bottle-orm, a lightweight ORM for Rust |
| homepage | |
| repository | https://github.com/Murilinho145SG/bottle-orm |
| max_upload_size | |
| id | 2053019 |
| size | 45,128 |
This crate provides the procedural macros for Bottle ORM, specifically the #[derive(Model)] macro. It is used to automatically generate schema definitions and SQL mapping for your Rust structs.
Note: This crate is intended to be used as a dependency of
bottle-orm, not standalone. Please refer to the main bottle-orm documentation for usage instructions.
You should install the main crate:
[dependencies]
bottle-orm = "0.1.0"
However, if you need to inspect this macro crate specifically:
[dependencies]
bottle-orm-macro = "0.1.0"
You can use the #[orm(...)] attribute on struct fields to configure database constraints and types.
| Attribute | Description | Example |
|---|---|---|
primary_key |
Marks the column as the Primary Key. | #[orm(primary_key)] |
unique |
Adds a UNIQUE constraint to the column. | #[orm(unique)] |
index |
Creates a database index for this column. | #[orm(index)] |
create_time |
Sets the default value to the current timestamp (NOW()/CURRENT_TIMESTAMP). |
#[orm(create_time)] |
size = N |
Sets the column size (e.g., VARCHAR(N)). Defaults to TEXT if omitted. |
#[orm(size = 255)] |
foreign_key = "Table::Column" |
Defines a Foreign Key relationship. | #[orm(foreign_key = "User::id")] |
This project is licensed under the MIT License - see the LICENSE file for details.