Skip to main content

actix_cloud_extra/
entity.rs

1//! SeaORM entity helpers.
2
3use sea_orm::{ColumnTrait, FromJsonQueryResult};
4use serde::{Deserialize, Serialize};
5
6/// Wrapper of `Vec<String>` stored as a JSON array column (via
7/// [`FromJsonQueryResult`]).
8///
9/// Useful when an entity needs a simple list field without a join table.
10#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize, FromJsonQueryResult)]
11pub struct VecString(pub Vec<String>);
12
13/// Maps an entity to its default timestamp columns.
14///
15/// Usually implemented automatically by the `entity_timestamp` macro, and
16/// consumed by [`crate::api::Condition::add_time`] to filter on
17/// creation/update time ranges.
18pub trait DefaultColumnTrait {
19    /// Column storing the creation timestamp.
20    fn get_created_at() -> impl ColumnTrait;
21    /// Column storing the last update timestamp.
22    fn get_updated_at() -> impl ColumnTrait;
23}