[−][src]Struct butane_core::many::Many
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]
T: DataObject,
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]
&mut self,
item_table: &'static str,
owner: SqlVal,
owner_type: SqlType
)
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]
&self,
conn: &impl ConnectionMethods
) -> Result<impl Iterator<Item = &T>>
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]
T: DataObject,
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]
T: Send,
impl<T> !Sync for Many<T>
[src]
impl<T> Unpin for Many<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> UnwindSafe for Many<T> where
T: UnwindSafe,
[src]
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,