Struct pg_worm::query::TypedColumn
source · pub struct TypedColumn<T: ToSql + Sync> { /* private fields */ }Expand description
A wrapper around the Column struct which includes
the rust type of the field.
For each field of a pg_worm::Model a TypedColumn is automatically
generated.
A TypedColumn can be used to access information about
the column and create Filters regarding this column.
Example
use pg_worm::Model;
#[derive(Model)]
struct Foo {
baz: i64
}
assert_eq!(Foo::baz.column_name(), "baz");
Implementations§
source§impl<T: ToSql + Sync + Send + 'static> TypedColumn<T>
impl<T: ToSql + Sync + Send + 'static> TypedColumn<T>
pub const fn new( table_name: &'static str, column_name: &'static str ) -> TypedColumn<T>
pub const fn nullable(self) -> TypedColumn<T>
pub const fn unique(self) -> TypedColumn<T>
pub const fn primary_key(self) -> TypedColumn<T>
pub const fn generated(self) -> TypedColumn<T>
sourcepub fn eq(&self, value: impl Into<T>) -> Filter
pub fn eq(&self, value: impl Into<T>) -> Filter
Check whether the columns value is equal to value.
Translates to WHERE <column_name> = <value>.
sourcepub fn one_of(&self, values: Vec<impl Into<T>>) -> Filter
pub fn one_of(&self, values: Vec<impl Into<T>>) -> Filter
Check whether the columns value is one of values.
Translates to WHERE <column_name> IN <values>
pub fn is_null(&self) -> Filter
Methods from Deref<Target = Column>§
pub fn unique(&self) -> bool
pub fn nullable(&self) -> bool
pub fn primary_key(&self) -> bool
pub fn generated(&self) -> bool
sourcepub fn column_name(&self) -> &'static str
pub fn column_name(&self) -> &'static str
Get the column name.
sourcepub fn table_name(&self) -> &'static str
pub fn table_name(&self) -> &'static str
Get the name of the table this column is part of.
Trait Implementations§
source§impl<T: Clone + ToSql + Sync> Clone for TypedColumn<T>
impl<T: Clone + ToSql + Sync> Clone for TypedColumn<T>
source§fn clone(&self) -> TypedColumn<T>
fn clone(&self) -> TypedColumn<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<T: Copy + ToSql + Sync> Copy for TypedColumn<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for TypedColumn<T>where T: RefUnwindSafe,
impl<T> Send for TypedColumn<T>where T: Send,
impl<T> Sync for TypedColumn<T>
impl<T> Unpin for TypedColumn<T>where T: Unpin,
impl<T> UnwindSafe for TypedColumn<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more