[][src]Struct toql::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) -> SqlMapper 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) -> SqlMapper where
    H: 'static + FieldHandler + Send + Sync,
    T: Into<String>, 
[src]

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

pub fn insert_new_mapper<T>(
    cache: &mut HashMap<String, SqlMapper, RandomState>
) -> &mut SqlMapper where
    T: Mapped
[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 HashMap<String, SqlMapper, RandomState>,
    handler: H
) -> &mut SqlMapper where
    H: 'static + FieldHandler + Send + Sync,
    T: Mapped
[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>(sql_alias: &str) -> SqlMapper where
    T: Mapped
[src]

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

pub fn map_join<T>(
    &'a mut self,
    toql_path: &str,
    sql_alias: &str
) -> &'a mut SqlMapper where
    T: Mapped
[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<H>(
    &'a mut self,
    toql_field: &str,
    expression: &str,
    handler: H,
    options: MapperOptions
) -> &'a mut SqlMapper 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 SqlMapper 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 + 'static + Sync + Send>,
    options: MapperOptions
) -> &mut SqlMapper
[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 SqlMapper
[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 mut self,
    toql_field: &str,
    sql_field: &str
) -> &'a mut SqlMapper
[src]

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

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

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

pub fn join(
    &'a mut self,
    toql_path: &str,
    join_clause: &str
) -> &'a mut SqlMapper
[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 mut self,
    toql_path: &str,
    join_clause: &str
) -> &'a mut SqlMapper
[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> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<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> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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