[−][src]Struct mongodb::coll::Collection
Interfaces with a MongoDB collection.
Fields
db: Database
A reference to the database that spawned this collection.
namespace: String
The namespace of this collection, formatted as db_name.coll_name.
Methods
impl Collection
[src]
impl Collection
pub fn new(
db: Database,
name: &str,
create: bool,
read_preference: Option<ReadPreference>,
write_concern: Option<WriteConcern>
) -> Collection
[src]
pub fn new(
db: Database,
name: &str,
create: bool,
read_preference: Option<ReadPreference>,
write_concern: Option<WriteConcern>
) -> Collection
Creates a collection representation with optional read and write controls.
If create
is specified, the collection will be explicitly created in the database.
pub fn get_req_id(&self) -> i32
[src]
pub fn get_req_id(&self) -> i32
Returns a unique operational request id.
pub fn name(&self) -> String
[src]
pub fn name(&self) -> String
Extracts the collection name from the namespace. If the namespace is invalid, this method will panic.
pub fn drop(&self) -> Result<()>
[src]
pub fn drop(&self) -> Result<()>
Permanently deletes the collection from the database.
pub fn aggregate(
&self,
pipeline: Vec<Document>,
options: Option<AggregateOptions>
) -> Result<Cursor>
[src]
pub fn aggregate(
&self,
pipeline: Vec<Document>,
options: Option<AggregateOptions>
) -> Result<Cursor>
Runs an aggregation framework pipeline.
pub fn count(
&self,
filter: Option<Document>,
options: Option<CountOptions>
) -> Result<i64>
[src]
pub fn count(
&self,
filter: Option<Document>,
options: Option<CountOptions>
) -> Result<i64>
Gets the number of documents matching the filter.
pub fn distinct(
&self,
field_name: &str,
filter: Option<Document>,
options: Option<DistinctOptions>
) -> Result<Vec<Bson>>
[src]
pub fn distinct(
&self,
field_name: &str,
filter: Option<Document>,
options: Option<DistinctOptions>
) -> Result<Vec<Bson>>
Finds the distinct values for a specified field across a single collection.
pub fn find(
&self,
filter: Option<Document>,
options: Option<FindOptions>
) -> Result<Cursor>
[src]
pub fn find(
&self,
filter: Option<Document>,
options: Option<FindOptions>
) -> Result<Cursor>
Returns a list of documents within the collection that match the filter.
pub fn find_one(
&self,
filter: Option<Document>,
options: Option<FindOptions>
) -> Result<Option<Document>>
[src]
pub fn find_one(
&self,
filter: Option<Document>,
options: Option<FindOptions>
) -> Result<Option<Document>>
Returns the first document within the collection that matches the filter, or None.
pub fn find_one_with_command_type(
&self,
filter: Option<Document>,
options: Option<FindOptions>,
cmd_type: CommandType
) -> Result<Option<Document>>
[src]
pub fn find_one_with_command_type(
&self,
filter: Option<Document>,
options: Option<FindOptions>,
cmd_type: CommandType
) -> Result<Option<Document>>
pub fn find_one_and_delete(
&self,
filter: Document,
options: Option<FindOneAndDeleteOptions>
) -> Result<Option<Document>>
[src]
pub fn find_one_and_delete(
&self,
filter: Document,
options: Option<FindOneAndDeleteOptions>
) -> Result<Option<Document>>
Finds a single document and deletes it, returning the original.
pub fn find_one_and_replace(
&self,
filter: Document,
replacement: Document,
options: Option<FindOneAndUpdateOptions>
) -> Result<Option<Document>>
[src]
pub fn find_one_and_replace(
&self,
filter: Document,
replacement: Document,
options: Option<FindOneAndUpdateOptions>
) -> Result<Option<Document>>
Finds a single document and replaces it, returning either the original or replaced document.
pub fn find_one_and_update(
&self,
filter: Document,
update: Document,
options: Option<FindOneAndUpdateOptions>
) -> Result<Option<Document>>
[src]
pub fn find_one_and_update(
&self,
filter: Document,
update: Document,
options: Option<FindOneAndUpdateOptions>
) -> Result<Option<Document>>
Finds a single document and updates it, returning either the original or updated document.
pub fn bulk_write(
&self,
requests: Vec<WriteModel>,
ordered: bool
) -> BulkWriteResult
[src]
pub fn bulk_write(
&self,
requests: Vec<WriteModel>,
ordered: bool
) -> BulkWriteResult
Sends a batch of writes to the server at the same time.
pub fn insert_one(
&self,
doc: Document,
write_concern: Option<WriteConcern>
) -> Result<InsertOneResult>
[src]
pub fn insert_one(
&self,
doc: Document,
write_concern: Option<WriteConcern>
) -> Result<InsertOneResult>
Inserts the provided document. If the document is missing an identifier, the driver should generate one.
pub fn insert_many(
&self,
docs: Vec<Document>,
options: Option<InsertManyOptions>
) -> Result<InsertManyResult>
[src]
pub fn insert_many(
&self,
docs: Vec<Document>,
options: Option<InsertManyOptions>
) -> Result<InsertManyResult>
Inserts the provided documents. If any documents are missing an identifier, the driver should generate them.
pub fn delete_one(
&self,
filter: Document,
write_concern: Option<WriteConcern>
) -> Result<DeleteResult>
[src]
pub fn delete_one(
&self,
filter: Document,
write_concern: Option<WriteConcern>
) -> Result<DeleteResult>
Deletes a single document.
pub fn delete_many(
&self,
filter: Document,
write_concern: Option<WriteConcern>
) -> Result<DeleteResult>
[src]
pub fn delete_many(
&self,
filter: Document,
write_concern: Option<WriteConcern>
) -> Result<DeleteResult>
Deletes multiple documents.
pub fn replace_one(
&self,
filter: Document,
replacement: Document,
options: Option<ReplaceOptions>
) -> Result<UpdateResult>
[src]
pub fn replace_one(
&self,
filter: Document,
replacement: Document,
options: Option<ReplaceOptions>
) -> Result<UpdateResult>
Replaces a single document.
pub fn update_one(
&self,
filter: Document,
update: Document,
options: Option<UpdateOptions>
) -> Result<UpdateResult>
[src]
pub fn update_one(
&self,
filter: Document,
update: Document,
options: Option<UpdateOptions>
) -> Result<UpdateResult>
Updates a single document.
pub fn update_many(
&self,
filter: Document,
update: Document,
options: Option<UpdateOptions>
) -> Result<UpdateResult>
[src]
pub fn update_many(
&self,
filter: Document,
update: Document,
options: Option<UpdateOptions>
) -> Result<UpdateResult>
Updates multiple documents.
pub fn create_index(
&self,
keys: Document,
options: Option<IndexOptions>
) -> Result<String>
[src]
pub fn create_index(
&self,
keys: Document,
options: Option<IndexOptions>
) -> Result<String>
Create a single index.
pub fn create_index_model(&self, model: IndexModel) -> Result<String>
[src]
pub fn create_index_model(&self, model: IndexModel) -> Result<String>
Create a single index with an IndexModel.
pub fn create_indexes(&self, models: Vec<IndexModel>) -> Result<Vec<String>>
[src]
pub fn create_indexes(&self, models: Vec<IndexModel>) -> Result<Vec<String>>
Create multiple indexes.
pub fn drop_index(
&self,
keys: Document,
options: Option<IndexOptions>
) -> Result<()>
[src]
pub fn drop_index(
&self,
keys: Document,
options: Option<IndexOptions>
) -> Result<()>
Drop an index.
pub fn drop_index_string(&self, name: String) -> Result<()>
[src]
pub fn drop_index_string(&self, name: String) -> Result<()>
Drop an index by name.
pub fn drop_index_model(&self, model: IndexModel) -> Result<()>
[src]
pub fn drop_index_model(&self, model: IndexModel) -> Result<()>
Drop an index by IndexModel.
pub fn drop_indexes(&self) -> Result<()>
[src]
pub fn drop_indexes(&self) -> Result<()>
Drop all indexes in the collection.
pub fn list_indexes(&self) -> Result<Cursor>
[src]
pub fn list_indexes(&self) -> Result<Cursor>
List all indexes in the collection.
Trait Implementations
Auto Trait Implementations
impl Send for Collection
impl Send for Collection
impl Sync for Collection
impl Sync for Collection
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T, U> TryInto for T where
U: TryFrom<T>,
impl<T, U> TryInto for T where
U: TryFrom<T>,
impl<T> Same for T
impl<T> Same for T
type Output = T
Should always be Self