Struct mongod::Client [−][src]
An asynchronous Client
to query mongo with.
The client uses sane defaults but these can be tweaked using the builder. To configure a
Client
, use Client::builder
.
The Client
holds a connection pool internally, so it is advised that you create once, and
reuse it.
Implementations
impl Client
[src]
pub fn new() -> Self
[src]
Constructs a new Client
.
Panics
This method panics if the mongodb::Client
fails to initialise.
Use Client::builder()
if you wish to handle this failure as an Error
instead of
panicking.
pub fn builder() -> ClientBuilder
[src]
Creates a ClientInner
to configure a Client
.
This is the same as ClientBuilder::new()
.
pub fn from_client<I: Into<String>>(client: Client, database: I) -> Self
[src]
Constructs a new Client
using a mongodb::Client
.
pub fn client(&self) -> Client
[src]
Returns the mongodb::Client
pub fn collection<C>(&self) -> Collection where
C: Collection,
[src]
C: Collection,
Returns the mongodb::Document
from the mongodb.
pub fn database(&self) -> Database
[src]
Returns the mongodb::Database
from the mongodb.
pub async fn delete<C, F>(&self, filter: Option<F>) -> Result<i64, Error> where
C: AsFilter<F> + Collection,
F: Filter,
[src]
C: AsFilter<F> + Collection,
F: Filter,
Convenience method to delete documents from a collection using a given filter.
Errors
This method fails if the mongodb encountered an error.
pub async fn delete_one<C, F>(&self, filter: F) -> Result<bool, Error> where
C: AsFilter<F> + Collection,
F: Filter,
[src]
C: AsFilter<F> + Collection,
F: Filter,
Convenience method to delete one document from a collection using a given filter.
Errors
This method fails if the mongodb encountered an error.
pub async fn find<C, F>(&self, filter: Option<F>) -> Result<Cursor, Error> where
C: AsFilter<F> + Collection,
F: Filter,
[src]
C: AsFilter<F> + Collection,
F: Filter,
Convenience method to find documents in a collection.
This function is mainly intended for use cases where the filter is known to return unique
hits. If you need something more complicated use find
or the FindBuilder
.
Errors
This method fails if the mongodb encountered an error.
pub async fn find_one<C, F>(&self, filter: F) -> Result<Option<C>, Error> where
C: AsFilter<F> + Collection,
F: Filter,
[src]
C: AsFilter<F> + Collection,
F: Filter,
Convenience method to find a document in a collection using a given filter.
This function is mainly intended for use cases where the filter is known to return unique
hits. If you need something more complicated use find
or the FindBuilder
.
Errors
This method fails if the mongodb encountered an error, or if the found document is invalid.
pub async fn insert<C>(
&self,
documents: Vec<C>
) -> Result<HashMap<usize, ObjectId>, Error> where
C: Collection,
[src]
&self,
documents: Vec<C>
) -> Result<HashMap<usize, ObjectId>, Error> where
C: Collection,
Convenience method to insert documents in a collection.
Errors
This method fails if the mongodb encountered an error, or if the found document is invalid.
pub async fn insert_one<C>(&self, document: C) -> Result<ObjectId, Error> where
C: Collection,
[src]
C: Collection,
Convenience method to insert a document in a collection.
Errors
This method fails if the mongodb encountered an error, or if the found document is invalid.
pub async fn replace_one<C, F>(
&self,
filter: F,
document: C
) -> Result<bool, Error> where
C: AsFilter<F> + Collection,
F: Filter,
[src]
&self,
filter: F,
document: C
) -> Result<bool, Error> where
C: AsFilter<F> + Collection,
F: Filter,
Convenience method to replace a document in a collection.
Errors
This method fails if the mongodb encountered an error.
pub async fn update<C, F, U>(
&self,
filter: F,
updates: Updates<U>
) -> Result<i64, Error> where
C: AsFilter<F> + AsUpdate<U> + Collection,
F: Filter,
U: Update,
[src]
&self,
filter: F,
updates: Updates<U>
) -> Result<i64, Error> where
C: AsFilter<F> + AsUpdate<U> + Collection,
F: Filter,
U: Update,
Convenience method to update documents in a collection.
Errors
This method fails if the mongodb encountered an error.
pub async fn update_one<C, F, U>(
&self,
filter: F,
updates: Updates<U>
) -> Result<bool, Error> where
C: AsFilter<F> + AsUpdate<U> + Collection,
F: Filter,
U: Update,
[src]
&self,
filter: F,
updates: Updates<U>
) -> Result<bool, Error> where
C: AsFilter<F> + AsUpdate<U> + Collection,
F: Filter,
U: Update,
Convenience method to update one document from a collection.
Errors
This method fails if the mongodb encountered an error.
pub async fn upsert<C, F, U>(
&self,
filter: F,
updates: Updates<U>
) -> Result<i64, Error> where
C: AsFilter<F> + AsUpdate<U> + Collection,
F: Filter,
U: Update,
[src]
&self,
filter: F,
updates: Updates<U>
) -> Result<i64, Error> where
C: AsFilter<F> + AsUpdate<U> + Collection,
F: Filter,
U: Update,
Convenience method to upsert documents from a collection.
Errors
This method fails if the mongodb encountered an error.
pub async fn upsert_one<C, F, U>(
&self,
filter: F,
updates: Updates<U>
) -> Result<bool, Error> where
C: AsFilter<F> + AsUpdate<U> + Collection,
F: Filter,
U: Update,
[src]
&self,
filter: F,
updates: Updates<U>
) -> Result<bool, Error> where
C: AsFilter<F> + AsUpdate<U> + Collection,
F: Filter,
U: Update,
Convenience method to upsert one document from a collection.
Errors
This method fails if the mongodb encountered an error.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,