Struct polodb_core::Collection

source ·
pub struct Collection<'a, T> { /* private fields */ }
Expand description

A wrapper of collection in struct.

All CURD methods can be done through this structure.

It can be used to perform collection-level operations such as CRUD operations.

Implementations§

source§

impl<'a, T> Collection<'a, T>

source

pub fn name(&self) -> &str

source

pub fn count_documents(&self) -> DbResult<u64>

Return the size of all data in the collection.

source

pub fn count_documents_with_session( &self, session: &mut ClientSession<'_> ) -> DbResult<u64>

Return the size of all data in the collection.

source

pub fn update_one( &self, query: Document, update: Document ) -> DbResult<UpdateResult>

Updates up to one document matching query in the collection. documentation for more information on specifying updates.

source

pub fn update_one_with_session( &self, query: Document, update: Document, session: &mut ClientSession<'_> ) -> DbResult<UpdateResult>

Updates up to one document matching query in the collection. documentation for more information on specifying updates.

source

pub fn update_many( &self, query: Document, update: Document ) -> DbResult<UpdateResult>

Updates all documents matching query in the collection. documentation for more information on specifying updates.

source

pub fn update_many_with_session( &self, query: Document, update: Document, session: &mut ClientSession<'_> ) -> DbResult<UpdateResult>

Updates all documents matching query in the collection. documentation for more information on specifying updates.

source

pub fn delete_one(&self, query: Document) -> DbResult<DeleteResult>

Deletes up to one document found matching query.

source

pub fn delete_one_with_session( &self, query: Document, session: &mut ClientSession<'_> ) -> DbResult<DeleteResult>

Deletes up to one document found matching query.

source

pub fn delete_many(&self, query: Document) -> DbResult<DeleteResult>

When query is None, all the data in the collection will be deleted.

The size of data deleted returns.

source

pub fn delete_many_with_session( &self, query: Document, session: &mut ClientSession<'_> ) -> DbResult<DeleteResult>

When query is None, all the data in the collection will be deleted.

The size of data deleted returns.

source

pub fn drop(&self) -> DbResult<()>

source

pub fn drop_with_session(&self, session: &mut ClientSession<'_>) -> DbResult<()>

source§

impl<'a, T> Collection<'a, T>where T: Serialize,

source

pub fn insert_one(&self, doc: impl Borrow<T>) -> DbResult<InsertOneResult>

Inserts doc into the collection.

source

pub fn insert_one_with_session( &self, doc: impl Borrow<T>, session: &mut ClientSession<'_> ) -> DbResult<InsertOneResult>

Inserts doc into the collection.

source

pub fn insert_many( &self, docs: impl IntoIterator<Item = impl Borrow<T>> ) -> DbResult<InsertManyResult>

Inserts the data in docs into the collection.

source

pub fn insert_many_with_session( &self, docs: impl IntoIterator<Item = impl Borrow<T>>, session: &mut ClientSession<'_> ) -> DbResult<InsertManyResult>

Inserts the data in docs into the collection.

source§

impl<'a, T> Collection<'a, T>where T: DeserializeOwned,

source

pub fn find_many(&self, filter: impl Into<Option<Document>>) -> DbResult<Vec<T>>

When query document is passed to the function. The result satisfies the query document.

source

pub fn find_many_with_session( &self, filter: impl Into<Option<Document>>, session: &mut ClientSession<'_> ) -> DbResult<Vec<T>>

When query document is passed to the function. The result satisfies the query document.

source

pub fn find_one( &self, filter: impl Into<Option<Document>> ) -> DbResult<Option<T>>

Return the first element in the collection satisfies the query.

source

pub fn find_one_with_session( &self, filter: impl Into<Option<Document>>, session: &mut ClientSession<'_> ) -> DbResult<Option<T>>

Return the first element in the collection satisfies the query.

Auto Trait Implementations§

§

impl<'a, T> RefUnwindSafe for Collection<'a, T>where T: RefUnwindSafe,

§

impl<'a, T> Send for Collection<'a, T>where T: Send,

§

impl<'a, T> Sync for Collection<'a, T>where T: Sync,

§

impl<'a, T> Unpin for Collection<'a, T>where T: Unpin,

§

impl<'a, T> UnwindSafe for Collection<'a, T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V