Crate diesel_versioning

Crate diesel_versioning 

Source
Expand description

§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.

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.

Traits§

Versioned
Trait that must be implemented by an entity, to support optimitsic locking. You would use the provided derive macro.
VersionedAsync
Trait that must be implemented by an entity, to support optimitsic locking. You would use the provided derive macro.

Derive Macros§

Versioned
Dervice macro to implement Versioned.
VersionedAsync
Dervice macro to implement VersionedAsync.