Trait orm_macro::OrmRepository

source ·
pub trait OrmRepository {
    // Required methods
    fn find(&self) -> String;
    fn select_fields(&mut self, fields: Vec<&str>) -> &mut Self;
    fn create(&mut self) -> &str;
    fn update(&self) -> &str;
    fn delete(&self) -> &str;
}
Expand description

This trait contains the methods that generate sql

Required Methods§

source

fn find(&self) -> String

generate: SELECT {struct_fields} from {table_name}

source

fn select_fields(&mut self, fields: Vec<&str>) -> &mut Self

👎Deprecated since 1.2.0: Removing this unnecesary method will make find() return &str instead of String, in the future there will be better find methods

Used to specify which fields to select

source

fn create(&mut self) -> &str

generate: INSERT INTO {table_name} ({struct_fields}) VALUES({$1,$2…}) RETURNING {struct_fields}

source

fn update(&self) -> &str

generate: UPDATE {table_name} SET struct_field1 = $1 , WHERE id = $2 RETURNING {struct_fields} {struct_fields}

source

fn delete(&self) -> &str

generates: DELETE FROM {table_name} WHERE id = $1 RETURNING {struct_fields}

Object Safety§

This trait is not object safe.

Implementors§