Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theduke/diesel_derive_table
Derive table structs for Rust's Diesel ORM.
https://github.com/theduke/diesel_derive_table
Last synced: about 1 month ago
JSON representation
Derive table structs for Rust's Diesel ORM.
- Host: GitHub
- URL: https://github.com/theduke/diesel_derive_table
- Owner: theduke
- Created: 2017-08-08T21:27:21.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-29T10:26:10.000Z (over 6 years ago)
- Last Synced: 2024-10-14T17:21:39.000Z (2 months ago)
- Language: Rust
- Size: 3.91 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# diesel_derive_table
This crates provides additional derive functionality for [Diesel][diesel],
an ORM for Rust.## Why
Diesel requires you to either infer the schema from the database, dump the
database to schema definitions with a CLI command, or specify table schemas
with the `table!` macro.Non of those options really suit my workflow.
This crate contains one custom_derive implementation, `#derive[(Table)]`.
It gives you the ability to define a struct for your table, and also auto-generate
the table! macro for diesel.## How to use
```rust
#[macro_use] extern crate diesel_derive_table#[derive(Table, Queryable, AsChangeset, Insertable, Identifiable)]
#[table_name="reddit_posts"]
#[primary_key(uuid)]
pub struct RedditPost {
#[column_type="Text"]
#[column_name="my_uuid"]
pub uuid: String,
#[column_type="BigInt"]
pub created_at: i64,
}
```Notes:
* It supports Diesel's attributes (column_name, table_name, primary_key)
* provides additional attribute `column_type` for specifying the DB column type
* Requires you to specify additional derives, so you stay in control of what
should be derived.