Struct 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::prelude::*;

#[derive(Model)]
struct Foo {
    baz: i64
}

assert_eq!(Foo::baz.column_name(), "baz");

Implementations§

Source§

impl<T: ToSql + Sync + Send + 'static> TypedColumn<T>

Source

pub const fn new( table_name: &'static str, column_name: &'static str, ) -> TypedColumn<T>

Creates anew TypedColumn<T>.

Source

pub const fn nullable(self) -> TypedColumn<T>

Set this property so true.

Source

pub const fn unique(self) -> TypedColumn<T>

Set this property so true.

Source

pub const fn primary_key(self) -> TypedColumn<T>

Set this property so true.

Source

pub const fn generated(self) -> TypedColumn<T>

Set this property so true.

Source

pub fn eq<'a>(&self, other: &'a T) -> Where<'a>

Returns a Where clause which checks whether this column is equal to some value.

Source§

impl<T: ToSql + Sync + Send + 'static + PartialOrd> TypedColumn<T>

Source

pub fn gt<'a>(&self, other: &'a T) -> Where<'a>

Check whether this column’s value is greater than some other value.

Source

pub fn gte<'a>(&self, other: &'a T) -> Where<'a>

Check whether this colum’s value is greater than or equal to another value.

Source

pub fn lt<'a>(&self, other: &'a T) -> Where<'a>

Check whether this column’s value is less than some other value.

Source

pub fn lte<'a>(&self, other: &'a T) -> Where<'a>

Check whether this colum’s value is less than or equal to another value.

Source§

impl<'a, T: ToSql + Sync + 'a> TypedColumn<Option<T>>

Source

pub fn null(&self) -> Where<'a>

Check whether this column’s value is NULL.

Source

pub fn not_noll(&self) -> Where<'a>

Check whether this column’s value is NOT NULL

Source§

impl<'a, T: ToSql + Sync + 'a> TypedColumn<Vec<T>>

Source

pub fn contains(&self, value: &'a T) -> Where<'a>

Check whether this column’s array contains some value.

Source

pub fn contains_not(&self, value: &'a T) -> Where<'a>

Check whether this column’s array does NOT contain some value.

Source

pub fn contains_any(&self, values: &'a Vec<&'a T>) -> Where<'a>

Check whether this column’s array contains any value of another array.

Source

pub fn contains_all(&self, values: &'a Vec<&'a T>) -> Where<'a>

Check whether this column’s array contains all values of another array.

Source

pub fn contains_none(&self, values: &'a Vec<&'a T>) -> Where<'a>

Check whether this column’s array does not overlap with another array, i.e. contains none of its values.

Source§

impl<'a> TypedColumn<String>

Source

pub fn contains(&self, other: &'a String) -> Where<'a>

Check whethre a string contains a substring. Case sensitive.

Methods from Deref<Target = Column>§

Source

pub fn unique(&self) -> bool

Returns this propertie’s value.

Source

pub fn nullable(&self) -> bool

Returns this propertie’s value.

Source

pub fn primary_key(&self) -> bool

Returns this propertie’s value.

Source

pub fn generated(&self) -> bool

Returns this propertie’s value.

Source

pub fn column_name(&self) -> &'static str

Get the column name.

Source

pub fn table_name(&self) -> &'static str

Get the name of the table this column is part of.

Source

pub fn full_name(&self) -> String

Get the full name of the column.

§Example
use pg_worm::prelude::*;

#[derive(Model)]
struct Foo {
    baz: String
}
assert_eq!(Foo::baz.full_name(), "foo.baz");

Trait Implementations§

Source§

impl<T: Clone + ToSql + Sync> Clone for TypedColumn<T>

Source§

fn clone(&self) -> TypedColumn<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + ToSql + Sync> Debug for TypedColumn<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ToSql + Sync> Deref for TypedColumn<T>

Source§

type Target = Column

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T: Copy + ToSql + Sync> Copy for TypedColumn<T>

Auto Trait Implementations§

§

impl<T> Freeze for TypedColumn<T>

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V