4 stable releases
Uses old Rust 2015
1.1.3 | Apr 3, 2018 |
---|---|
1.1.1 | Feb 25, 2018 |
#133 in #diesel
50 downloads per month
10KB
160 lines
diesel-derive-more
This package provides some helpers for working with diesel models.
Provides
- DefaultInsertable: Creates a default struct to use as an insertable model
- DBEnum: Allows serializing and deserializing enums for DB storage
- Deserialization for default insertable through the 'serialization' feature
This is work in progress (created to support one of my projects) so it will continue to evolve.
Testing
Create a postgres test db and add a .env file to the root of the project pointing to that db
DATABASE_URL=postgres://dev:password@127.0.0.1/dev
Initialize the db by running:
pushd tests && diesel migration run && popd
You can run this when you make changes to the test schemas as well
lib.rs
:
Diesel Derive More
Additional derive functionality for the diesel models which make it easier to get started
DBEnum
DBEnum provides diesel implementations for using an enum as a string field in models. Deriving DBEnum in an enum provides serializationa and deserialization traits.
DefaultInsertable
Default insertable provides a default implementation for a diesel model It allows marking fields as auto_increment so that they are excluded from the derived struct.
The new struct is prefixed with 'New' and lives in the same module as the original struct.
When using the serialization feature, the stuct is also serializable through serde
Examples
For examples of usage check the corresponding tests in the tests/ dir
Dependencies
~5.5MB
~113K SLoC