pub enum HasManyModel<E>where
E: EntityTrait,{
NotSet,
Replace(Vec<<E as EntityTrait>::ActiveModelEx>),
Append(Vec<<E as EntityTrait>::ActiveModelEx>),
}Expand description
Container for 1-N or M-N related Models
Variants§
NotSet
Unspecified value, do nothing
Replace(Vec<<E as EntityTrait>::ActiveModelEx>)
Replace all items with this value set; delete leftovers
Append(Vec<<E as EntityTrait>::ActiveModelEx>)
Add new items to this has many relation; do not delete
Implementations§
Source§impl<E> HasManyModel<E>where
E: EntityTrait,
impl<E> HasManyModel<E>where
E: EntityTrait,
Sourcepub fn take(&mut self) -> HasManyModel<E>
pub fn take(&mut self) -> HasManyModel<E>
Take ownership of the models, leaving NotSet in place
Sourcepub fn as_slice(&self) -> &[<E as EntityTrait>::ActiveModelEx]
pub fn as_slice(&self) -> &[<E as EntityTrait>::ActiveModelEx]
Borrow models as slice
Sourcepub fn as_mut_vec(&mut self) -> &mut Vec<<E as EntityTrait>::ActiveModelEx>
pub fn as_mut_vec(&mut self) -> &mut Vec<<E as EntityTrait>::ActiveModelEx>
Get a mutable vec. If self is NotSet, convert to append.
Sourcepub fn into_vec(self) -> Vec<<E as EntityTrait>::ActiveModelEx>
pub fn into_vec(self) -> Vec<<E as EntityTrait>::ActiveModelEx>
Consume self as vector
Sourcepub fn empty_holder(&self) -> HasManyModel<E>
pub fn empty_holder(&self) -> HasManyModel<E>
Returns an empty container of self
Sourcepub fn push<AM>(&mut self, model: AM) -> &mut HasManyModel<E>
pub fn push<AM>(&mut self, model: AM) -> &mut HasManyModel<E>
Push an item to self
Sourcepub fn append<AM>(&mut self, model: AM) -> &mut HasManyModel<E>
pub fn append<AM>(&mut self, model: AM) -> &mut HasManyModel<E>
Push an item to self, but convert Replace to Append
Sourcepub fn replace_all<I>(&mut self, models: I) -> &mut HasManyModel<E>
pub fn replace_all<I>(&mut self, models: I) -> &mut HasManyModel<E>
Replace all items in this set
Sourcepub fn convert_to_append(&mut self) -> &mut HasManyModel<E>
pub fn convert_to_append(&mut self) -> &mut HasManyModel<E>
Convert self to Append, if set
Sourcepub fn is_replace(&self) -> bool
pub fn is_replace(&self) -> bool
If self is Replace
Sourcepub fn is_changed(&self) -> bool
pub fn is_changed(&self) -> bool
Return true if self is Replace or any containing model is changed
Sourcepub fn find(&self, model: &<E as EntityTrait>::Model) -> bool
pub fn find(&self, model: &<E as EntityTrait>::Model) -> bool
Find within the models by primary key, return true if found
Sourcepub fn try_into_model(self) -> Result<HasMany<E>, DbErr>
pub fn try_into_model(self) -> Result<HasMany<E>, DbErr>
Convert this back to a ModelEx container
Trait Implementations§
Source§impl<E> Clone for HasManyModel<E>
impl<E> Clone for HasManyModel<E>
Source§fn clone(&self) -> HasManyModel<E>
fn clone(&self) -> HasManyModel<E>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<E> Debug for HasManyModel<E>
impl<E> Debug for HasManyModel<E>
Source§impl<E> Default for HasManyModel<E>where
E: EntityTrait,
impl<E> Default for HasManyModel<E>where
E: EntityTrait,
Source§fn default() -> HasManyModel<E>
fn default() -> HasManyModel<E>
impl<E> Eq for HasManyModel<E>
Source§impl<E> From<Vec<<E as EntityTrait>::ActiveModelEx>> for HasManyModel<E>where
E: EntityTrait,
Converts from a set of models into Append, which performs non-destructive action
impl<E> From<Vec<<E as EntityTrait>::ActiveModelEx>> for HasManyModel<E>where
E: EntityTrait,
Converts from a set of models into Append, which performs non-destructive action
Source§fn from(value: Vec<<E as EntityTrait>::ActiveModelEx>) -> HasManyModel<E>
fn from(value: Vec<<E as EntityTrait>::ActiveModelEx>) -> HasManyModel<E>
Source§impl<E> Index<usize> for HasManyModel<E>where
E: EntityTrait,
impl<E> Index<usize> for HasManyModel<E>where
E: EntityTrait,
Source§type Output = <E as EntityTrait>::ActiveModelEx
type Output = <E as EntityTrait>::ActiveModelEx
Source§impl<E> IndexMut<usize> for HasManyModel<E>where
E: EntityTrait,
impl<E> IndexMut<usize> for HasManyModel<E>where
E: EntityTrait,
Source§impl<E> IntoIterator for HasManyModel<E>where
E: EntityTrait,
impl<E> IntoIterator for HasManyModel<E>where
E: EntityTrait,
Source§type Item = <E as EntityTrait>::ActiveModelEx
type Item = <E as EntityTrait>::ActiveModelEx
Source§type IntoIter = IntoIter<<E as EntityTrait>::ActiveModelEx>
type IntoIter = IntoIter<<E as EntityTrait>::ActiveModelEx>
Source§fn into_iter(self) -> <HasManyModel<E> as IntoIterator>::IntoIter
fn into_iter(self) -> <HasManyModel<E> as IntoIterator>::IntoIter
Source§impl<E> PartialEq for HasManyModel<E>
impl<E> PartialEq for HasManyModel<E>
Source§fn eq(&self, other: &HasManyModel<E>) -> bool
fn eq(&self, other: &HasManyModel<E>) -> bool
self and other values to be equal, and is used by ==.Auto Trait Implementations§
impl<E> Freeze for HasManyModel<E>
impl<E> RefUnwindSafe for HasManyModel<E>
impl<E> Send for HasManyModel<E>
impl<E> Sync for HasManyModel<E>
impl<E> Unpin for HasManyModel<E>
impl<E> UnsafeUnpin for HasManyModel<E>
impl<E> UnwindSafe for HasManyModel<E>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more