Struct polodb_core::db::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>
impl<'a, T> Collection<'a, T>
pub fn name(&self) -> &str
sourcepub fn count_documents(&self) -> DbResult<u64>
pub fn count_documents(&self) -> DbResult<u64>
Return the size of all data in the collection.
sourcepub fn update_one(
&self,
query: Document,
update: Document
) -> DbResult<UpdateResult>
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.
sourcepub fn update_many(
&self,
query: Document,
update: Document
) -> DbResult<UpdateResult>
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.
sourcepub fn delete_one(&self, query: Document) -> DbResult<DeleteResult>
pub fn delete_one(&self, query: Document) -> DbResult<DeleteResult>
Deletes up to one document found matching query
.
sourcepub fn delete_many(&self, query: Document) -> DbResult<DeleteResult>
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.
pub fn drop(&self) -> DbResult<()>
source§impl<'a, T> Collection<'a, T>where
T: Serialize,
impl<'a, T> Collection<'a, T>where
T: Serialize,
sourcepub fn insert_one(&self, doc: impl Borrow<T>) -> DbResult<InsertOneResult>
pub fn insert_one(&self, doc: impl Borrow<T>) -> DbResult<InsertOneResult>
Inserts doc
into the collection.
sourcepub fn insert_many(
&self,
docs: impl IntoIterator<Item = impl Borrow<T>>
) -> DbResult<InsertManyResult>
pub fn insert_many(
&self,
docs: impl IntoIterator<Item = impl Borrow<T>>
) -> DbResult<InsertManyResult>
Inserts the data in docs
into the collection.