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ยง
Sourceยงimpl<E> HasManyModel<E>where
E: EntityTrait,
impl<E> HasManyModel<E>where
E: EntityTrait,
Sourcepub fn as_slice(&self) -> &[E::ActiveModelEx]
pub fn as_slice(&self) -> &[E::ActiveModelEx]
Borrow models as slice
Sourcepub 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.
Sourcepub fn into_vec(self) -> Vec<E::ActiveModelEx>
pub fn into_vec(self) -> Vec<E::ActiveModelEx>
Consume self as vector
Sourcepub fn empty_holder(&self) -> Self
pub fn empty_holder(&self) -> Self
Returns an empty container of self
Sourcepub 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
Sourcepub 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
Sourcepub 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
Sourcepub fn convert_to_append(&mut self) -> &mut Self
pub fn convert_to_append(&mut self) -> &mut Self
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::Model) -> bool
pub fn find(&self, model: &E::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 + EntityTrait> Clone for HasManyModel<E>where
E::ActiveModelEx: Clone,
impl<E: Clone + EntityTrait> Clone for HasManyModel<E>where
E::ActiveModelEx: Clone,
Sourceยงfn clone(&self) -> HasManyModel<E>
fn clone(&self) -> HasManyModel<E>
Returns a duplicate of the value. Read more
1.0.0ยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSourceยงimpl<E: Debug + EntityTrait> Debug for HasManyModel<E>where
E::ActiveModelEx: Debug,
impl<E: Debug + EntityTrait> Debug for HasManyModel<E>where
E::ActiveModelEx: Debug,
Sourceยงimpl<E: EntityTrait> Default for HasManyModel<E>
impl<E: EntityTrait> Default for HasManyModel<E>
Sourceยงfn default() -> HasManyModel<E>
fn default() -> HasManyModel<E>
Returns the โdefault valueโ for a type. Read more
Sourceยงimpl<E: EntityTrait> From<HasManyModel<E>> for Option<Vec<E::ActiveModelEx>>
impl<E: EntityTrait> From<HasManyModel<E>> for Option<Vec<E::ActiveModelEx>>
Sourceยงfn from(value: HasManyModel<E>) -> Self
fn from(value: HasManyModel<E>) -> Self
Converts to this type from the input type.
Sourceยง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
Sourceยงfn from(value: Vec<E::ActiveModelEx>) -> Self
fn from(value: Vec<E::ActiveModelEx>) -> Self
Converts to this type from the input type.
Sourceยงimpl<E: EntityTrait> Index<usize> for HasManyModel<E>
impl<E: EntityTrait> Index<usize> for HasManyModel<E>
Sourceยงimpl<E: EntityTrait> IndexMut<usize> for HasManyModel<E>
impl<E: EntityTrait> IndexMut<usize> for HasManyModel<E>
Sourceยงimpl<E: EntityTrait> IntoIterator for HasManyModel<E>
impl<E: EntityTrait> IntoIterator for HasManyModel<E>
Sourceยงtype Item = <E as EntityTrait>::ActiveModelEx
type Item = <E as EntityTrait>::ActiveModelEx
The type of the elements being iterated over.
Sourceยงtype IntoIter = IntoIter<<E as EntityTrait>::ActiveModelEx>
type IntoIter = IntoIter<<E as EntityTrait>::ActiveModelEx>
Which kind of iterator are we turning this into?
Sourceยง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ยง
ยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
ยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
ยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
ยงunsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
๐ฌThis is a nightly-only experimental API. (
clone_to_uninit)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>
Converts
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>
Converts
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