-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fdb012
commit 03ff58d
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Rene Klacan | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# sea-orm-typed-id | ||
|
||
[](https://crates.io/crates/sea-orm-typed-id) | ||
[](https://opensource.org/licenses/MIT) | ||
|
||
A Rust library that provides a macro for generating type-safe database ID types for SeaORM. | ||
|
||
## Caveat | ||
|
||
You might actually not need this library, it's just a macro and you might be better off with just copying the code from [src/lib.rs](src/lib.rs) into your project. | ||
|
||
### Features | ||
|
||
- `all`: Enables all features | ||
- `serde`: Enables serde support for serialization/deserialization | ||
- `rustls`: Enables rustls TLS backend for SeaORM | ||
- `postgres`: Enables PostgreSQL array support | ||
- `utoipa`: Enables OpenAPI schema generation support | ||
|
||
## Installation | ||
|
||
Add this to your `Cargo.toml`: | ||
|
||
```toml | ||
[dependencies] | ||
sea-orm-typed-id = { version = "0.1.0", features = ["all"] } | ||
``` | ||
|
||
## Usage | ||
|
||
```rust | ||
use sea_orm_typed_id::define_id; | ||
|
||
define_id!(UserId); | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] | ||
#[sea_orm(table_name = "cakes")] | ||
pub struct Cake { | ||
pub id: CakeId, | ||
} | ||
|
||
define_id!(FillingId); | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] | ||
#[sea_orm(table_name = "fillings")] | ||
pub struct Filling { | ||
pub id: FillingId, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] | ||
#[sea_orm(table_name = "cake_fillings")] | ||
pub struct CakeFilling { | ||
pub cake_id: CakeId, | ||
pub filling_id: FillingId, | ||
} | ||
``` | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |