pub struct Collection<T: StandardObject> { /* private fields */ }Expand description
Collections.
Implementations§
Source§impl<T: StandardObject> Collection<T>
impl<T: StandardObject> Collection<T>
pub fn new() -> Self
Sourcepub fn find(&self, search: &StdPropsFilter) -> HashSet<T>
pub fn find(&self, search: &StdPropsFilter) -> HashSet<T>
Finds all objects with properties matching the search criteria.
Sourcepub fn find_one(&self, search: &StdPropsFilter) -> Option<T>
pub fn find_one(&self, search: &StdPropsFilter) -> Option<T>
Finds a single instance of an object with properties matching the search filter.
Sourcepub fn insert_one(&mut self, obj: T) -> Result
pub fn insert_one(&mut self, obj: T) -> Result
Inserts a single object into the database.
§Errors
- If an object with the same resource id already exists.
Sourcepub fn update_one(&mut self, search: &RidFilter, obj: T) -> Result<T>
pub fn update_one(&mut self, search: &RidFilter, obj: T) -> Result<T>
Sourcepub fn update_or_insert_one(
&mut self,
search: &RidFilter,
obj: T,
) -> Result<Option<T>>
pub fn update_or_insert_one( &mut self, search: &RidFilter, obj: T, ) -> Result<Option<T>>
Updates an object if one is found, otherwise inserts it as new. If inserting a new object, the resource id is taken as is. If updating a previous object, the resource id aremains as the original’s.
§Returns
None if the object was newly inserted, or Some with the old value if it was updated.
§Errors
- If more than one object matches the search.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Collection<T>
impl<T> RefUnwindSafe for Collection<T>where
T: RefUnwindSafe,
impl<T> Send for Collection<T>where
T: Send,
impl<T> Sync for Collection<T>where
T: Sync,
impl<T> Unpin for Collection<T>where
T: Unpin,
impl<T> UnwindSafe for Collection<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more