[][src]Struct toql_core::sql_mapper::SqlMapper

pub struct SqlMapper { /* fields omitted */ }

Maps from Toql fields onto columns or SQL expressions.

Methods

impl SqlMapper[src]

pub fn new<T>(table: T) -> Self where
    T: Into<String>, 
[src]

Create new mapper for table or table alias. Example: ::new("Book") or new("Book b"). If you use an alias you must map all SQL columns with the alias too.

pub fn new_with_handler<T, H>(table: T, handler: H) -> Self where
    T: Into<String>,
    H: 'static + FieldHandler + Send + Sync
[src]

Creates new mapper with a custom handler. Use this to provide custom filter functions for all fields.

pub fn insert_new_mapper<T: Mapped>(
    cache: &mut SqlMapperCache
) -> &mut SqlMapper
[src]

Creates and inserts a new mapper into a cache. Returns a mutable reference to the created mapper. Use it for configuration.

pub fn insert_new_mapper_with_handler<T, H>(
    cache: &mut SqlMapperCache,
    handler: H
) -> &mut SqlMapper where
    T: Mapped,
    H: 'static + FieldHandler + Send + Sync
[src]

Creates a new mapper with a custom field handler and insert it into a cache. Returns a mutable reference to the created mapper. Use it for configuration.

pub fn map<T: Mapped>(sql_alias: &str) -> Self[src]

Maps all fields from a struct. This trait is implemented by the Toql derive for derived structs.

pub fn map_join<'a, T: Mapped>(
    &'a mut self,
    toql_path: &str,
    sql_alias: &str
) -> &'a mut Self
[src]

Maps all fields from a struct as a joined dependency. Example: To map for a user an Address struct that implements Mapped

This example is not tested
user_mapper.map_join<Address>("address", "a");

pub fn map_handler<'a, H>(
    &'a mut self,
    toql_field: &str,
    expression: &str,
    handler: H,
    options: MapperOptions
) -> &'a mut Self where
    H: 'static + FieldHandler + Send + Sync
[src]

Maps a Toql field to a field handler. This allows most freedom, you can define in the FieldHandler how to generate SQL for your field.

pub fn alter_handler<H>(&mut self, toql_field: &str, handler: H) -> &mut Self where
    H: 'static + FieldHandler + Send + Sync
[src]

Changes the handler of a field. This will panic if the field does not exist Use it to make changes, it prevents typing errors of field names.

pub fn alter_handler_with_options(
    &mut self,
    toql_field: &str,
    handler: Arc<dyn FieldHandler + Sync + Send>,
    options: MapperOptions
) -> &mut Self
[src]

Changes the handler and options of a field. This will panic if the field does not exist Use it to make changes, it prevents typing errors of field names.

pub fn alter_field(
    &mut self,
    toql_field: &str,
    sql_expression: &str,
    options: MapperOptions
) -> &mut Self
[src]

Changes the database column or SQL expression of a field. This will panic if the field does not exist Use it to make changes, it prevents typing errors of field names.

pub fn map_field<'a>(
    &'a mut self,
    toql_field: &str,
    sql_field: &str
) -> &'a mut Self
[src]

Adds a new field -or updates an existing field- to the mapper.

pub fn map_field_with_options<'a>(
    &'a mut self,
    toql_field: &str,
    sql_expression: &str,
    options: MapperOptions
) -> &'a mut Self
[src]

Adds a new field -or updates an existing field- to the mapper.

pub fn join<'a>(
    &'a mut self,
    toql_path: &str,
    join_clause: &str
) -> &'a mut Self
[src]

Adds a join for a given path to the mapper. Example: map.join("foo", "LEFT JOIN Foo f ON (foo_id = f.id)")

pub fn alter_join<'a>(
    &'a mut self,
    toql_path: &str,
    join_clause: &str
) -> &'a mut Self
[src]

Changes an already added join. This will panic if the join does not exist Use it to make changes, it prevents typing errors of path names.

Trait Implementations

impl Debug for SqlMapper[src]

Auto Trait Implementations

impl Send for SqlMapper

impl Sync for SqlMapper

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]