Enum HasManyModel
pub enum HasManyModel<E: EntityTrait> {
NotSet,
Replace(Vec<E::ActiveModelEx>),
Append(Vec<E::ActiveModelEx>),
}Expand description
Container for 1-N or M-N related Models
Variants§
NotSet
Unspecified value, do nothing
Replace(Vec<E::ActiveModelEx>)
Replace all items with this value set; delete leftovers
Append(Vec<E::ActiveModelEx>)
Add new items to this has many relation; do not delete
Implementations§
§impl<E> HasManyModel<E>where
E: EntityTrait,
impl<E> HasManyModel<E>where
E: EntityTrait,
pub fn take(&mut self) -> Self
pub fn take(&mut self) -> Self
Take ownership of the models, leaving NotSet in place
pub fn as_slice(&self) -> &[E::ActiveModelEx]
pub fn as_slice(&self) -> &[E::ActiveModelEx]
Borrow models as slice
pub fn as_mut_vec(&mut self) -> &mut Vec<E::ActiveModelEx>
pub fn as_mut_vec(&mut self) -> &mut Vec<E::ActiveModelEx>
Get a mutable vec. If self is NotSet, convert to append.
pub fn into_vec(self) -> Vec<E::ActiveModelEx>
pub fn into_vec(self) -> Vec<E::ActiveModelEx>
Consume self as vector
pub fn empty_holder(&self) -> Self
pub fn empty_holder(&self) -> Self
Returns an empty container of self
pub fn push<AM: Into<E::ActiveModelEx>>(&mut self, model: AM) -> &mut Self
pub fn push<AM: Into<E::ActiveModelEx>>(&mut self, model: AM) -> &mut Self
Push an item to self
pub fn append<AM: Into<E::ActiveModelEx>>(&mut self, model: AM) -> &mut Self
pub fn append<AM: Into<E::ActiveModelEx>>(&mut self, model: AM) -> &mut Self
Push an item to self, but convert Replace to Append
pub fn replace_all<I>(&mut self, models: I) -> &mut Selfwhere
I: IntoIterator<Item = E::ActiveModelEx>,
pub fn replace_all<I>(&mut self, models: I) -> &mut Selfwhere
I: IntoIterator<Item = E::ActiveModelEx>,
Replace all items in this set
pub fn convert_to_append(&mut self) -> &mut Self
pub fn convert_to_append(&mut self) -> &mut Self
Convert self to Append, if set
pub fn not_set(&mut self)
pub fn not_set(&mut self)
Reset self to NotSet
pub fn is_replace(&self) -> bool
pub fn is_replace(&self) -> bool
If self is Replace
pub fn is_changed(&self) -> bool
pub fn is_changed(&self) -> bool
Return true if self is Replace or any containing model is changed
pub fn find(&self, model: &E::Model) -> bool
pub fn find(&self, model: &E::Model) -> bool
Find within the models by primary key, return true if found
pub 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§
§impl<E: Clone + EntityTrait> Clone for HasManyModel<E>where
E::ActiveModelEx: Clone,
impl<E: Clone + EntityTrait> Clone for HasManyModel<E>where
E::ActiveModelEx: Clone,
§fn clone(&self) -> HasManyModel<E>
fn clone(&self) -> HasManyModel<E>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl<E: Debug + EntityTrait> Debug for HasManyModel<E>where
E::ActiveModelEx: Debug,
impl<E: Debug + EntityTrait> Debug for HasManyModel<E>where
E::ActiveModelEx: Debug,
§impl<E: EntityTrait> Default for HasManyModel<E>
impl<E: EntityTrait> Default for HasManyModel<E>
§fn default() -> HasManyModel<E>
fn default() -> HasManyModel<E>
§impl<E: EntityTrait> From<HasManyModel<E>> for Option<Vec<E::ActiveModelEx>>
impl<E: EntityTrait> From<HasManyModel<E>> for Option<Vec<E::ActiveModelEx>>
§fn from(value: HasManyModel<E>) -> Self
fn from(value: HasManyModel<E>) -> Self
§impl<E: EntityTrait> From<Vec<<E as EntityTrait>::ActiveModelEx>> for HasManyModel<E>
Converts from a set of models into Append, which performs non-destructive action
impl<E: EntityTrait> From<Vec<<E as EntityTrait>::ActiveModelEx>> for HasManyModel<E>
Converts from a set of models into Append, which performs non-destructive action
§fn from(value: Vec<E::ActiveModelEx>) -> Self
fn from(value: Vec<E::ActiveModelEx>) -> Self
§impl<E: EntityTrait> Index<usize> for HasManyModel<E>
impl<E: EntityTrait> Index<usize> for HasManyModel<E>
§type Output = <E as EntityTrait>::ActiveModelEx
type Output = <E as EntityTrait>::ActiveModelEx
§impl<E: EntityTrait> IndexMut<usize> for HasManyModel<E>
impl<E: EntityTrait> IndexMut<usize> for HasManyModel<E>
§impl<E: EntityTrait> IntoIterator for HasManyModel<E>
impl<E: EntityTrait> IntoIterator for HasManyModel<E>
§type Item = <E as EntityTrait>::ActiveModelEx
type Item = <E as EntityTrait>::ActiveModelEx
§type IntoIter = IntoIter<<E as EntityTrait>::ActiveModelEx>
type IntoIter = IntoIter<<E as EntityTrait>::ActiveModelEx>
§impl<E> PartialEq for HasManyModel<E>
impl<E> PartialEq for HasManyModel<E>
impl<E> Eq for HasManyModel<E>
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> 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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