[][src]Struct butane_core::many::Many

pub struct Many<T> where
    T: DataObject
{ /* fields omitted */ }

Used to implement a many-to-many relationship between models.

Creates a new table with columns "owner" and "has" If type T has a many-to-many relationship with U, owner type is T::PKType, has is U::PKType. Table name is T_ManyToMany_foo where foo is the name of the Many field

Implementations

impl<T> Many<T> where
    T: DataObject
[src]

pub fn new() -> Self[src]

Constructs a new Many. init must be called before it can be loaded or saved (or those methods will return Error::NotInitialized). init will automatically be called when a DataObject with a Many field is loaded or saved.

pub fn ensure_init(
    &mut self,
    item_table: &'static str,
    owner: SqlVal,
    owner_type: SqlType
)
[src]

Used by macro-generated code. You do not need to call this directly.

pub fn add(&mut self, new_val: &T)[src]

Adds a value.

pub fn get(&self) -> Result<impl Iterator<Item = &T>>[src]

Returns a reference to the value. It must have already been loaded. If not, returns Error::ValueNotLoaded

pub fn save(&mut self, conn: &impl ConnectionMethods) -> Result<()>[src]

Used by macro-generated code. You do not need to call this directly.

pub fn load(
    &self,
    conn: &impl ConnectionMethods
) -> Result<impl Iterator<Item = &T>>
[src]

Loads the values referred to by this foreign key from the database if necessary and returns a reference to the them.

pub fn columns(&self) -> [Column; 2][src]

Trait Implementations

impl<T: Debug> Debug for Many<T> where
    T: DataObject
[src]

impl<T: DataObject> Default for Many<T>[src]

impl<T: DataObject> Eq for Many<T>[src]

impl<T: DataObject> PartialEq<Many<T>> for Many<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Many<T>[src]

impl<T> Send for Many<T> where
    T: Send
[src]

impl<T> !Sync for Many<T>[src]

impl<T> Unpin for Many<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for Many<T> where
    T: UnwindSafe
[src]

Blanket Implementations

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

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

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

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.