1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Soft deletes for [SeaORM](https://www.sea-ql.org/SeaORM/): a row is moved to the
//! trash by setting `deleted_at`, can be restored, and is pruned for good later.
//!
//! ```
//! # mod posts {
//! # use sea_orm::entity::prelude::*;
//! # #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
//! # #[sea_orm(table_name = "posts")]
//! # pub struct Model {
//! # #[sea_orm(primary_key)]
//! # pub id: i32,
//! # pub category_id: i32,
//! # pub slug: String,
//! # pub deleted_at: Option<DateTimeWithTimeZone>,
//! # }
//! # #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
//! # pub enum Relation {}
//! # }
//! # impl sea_orm::ActiveModelBehavior for posts::ActiveModel {}
//! use sea_orm::{DatabaseConnection, DbErr, EntityTrait};
//! use sea_orm_soft_delete::{SoftDelete, SoftDeleteModel};
//!
//! impl SoftDelete for posts::Entity {
//! fn deleted_at_column() -> Self::Column {
//! posts::Column::DeletedAt
//! }
//! }
//!
//! async fn example(db: &DatabaseConnection, post: posts::Model) -> Result<(), DbErr> {
//! let post = post.soft_delete(db).await?; // deleted_at = now
//! let live = posts::Entity::find_without_trashed().all(db).await?;
//! let post = post.restore(db).await?; // deleted_at = NULL
//! Ok(())
//! }
//! # fn main() {}
//! ```
//!
//! `SeaORM` has no global query scopes, so `Entity::find()` still returns trashed
//! rows. Use [`SoftDelete::find_without_trashed`] or
//! [`TrashedQuery::without_trashed`] wherever trashed rows must stay hidden.
pub use SoftDelete;
pub use deny_hard_delete;
pub use SoftDeleteModel;
pub use TrashedQuery;
pub use ;