1 unstable release
Uses new Rust 2024
new 0.1.0 | May 15, 2025 |
---|
#1914 in Procedural macros
Used in diesel_versioning
15KB
285 lines
Diesel-Versioning
Diesel-Versioning implements optimistic locking for Diesel. This is achieved by an additional field on every entity, which should be support optimistic locking.
Getting started
The entity must have implemented diesel::AsChangeset
and diesel::Identifiable
to implement Versioned
. You can
use the provided derive macro.
use diesel::AsChangeset;
use diesel::Identifiable;
use diesel_versioning::Versioned;
#[derive(AsChangeset, Identifiable, Versioned)]
#[diesel(table_name = schema::users)]
#[diesel(check_for_backend(diesel::pg::Pg))]
pub struct User {
pub id: i32,
#[version]
pub version: i32,
pub body: String,
}
Currently only integer values are supported as version field.
If you use the feature-flag async
, you have to use VersionedAsync
instead of Versioned
.
License
Licensed under either of these:
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
Dependencies
~235–670KB
~15K SLoC