Skip to content

Select attributes

Andrey edited this page Oct 1, 2024 · 2 revisions

#[order_by] and #[order_by_desc]

Fields that are marked by these attributes - are used to render Order by part of SQL statement.

#[derive(SelectDbEntity)]
pub struct MyDto {

 #[order_by]
 pub dt_from: String,

}

$[wrap_column_name]

Wraps the content while rendering select field and replacing ${} with the name of the struct property name

#[derive(Debug, Clone, PartialEq, SelectDbEntity)]
pub struct DbInfoEntity {
    pub table_schema: Option<String>,
    pub table_name: Option<String>,
    #[wrap_column_name("pg_total_relation_size(table_schema || '.' || table_name) AS  ${}")]
    pub total_size: Option<i64>,
}
Clone this wiki locally