Struct mongod::query::Insert [−][src]
A querier to insert documents into a MongoDB collection.
Examples
Insert a document into a collection.
#[derive(Bson, Mongo)] #[mongo(collection="users", field, filter, update)] pub struct User { name: String, } let client = mongod::Client::new(); let user = User { name: "foo".to_owned() }; let result = mongod::query::Insert::<User>::new() .query(&client, vec![user]) .await .unwrap(); println!("(index: oid) {:?}", result);
Implementations
impl<C: Collection> Insert<C>
[src]
pub fn new() -> Self
[src]
Constructs a Insert
querier.
pub fn bypass_document_validation(self, enable: bool) -> Self
[src]
Opt out of document-level validation.
pub fn ordered(self, enable: bool) -> Self
[src]
If true, when an insert fails, return without performing the remaining writes. If false, when a write fails, continue with the remaining writes, if any.
Defaults to true.
pub fn write_concern(self, write_concern: WriteConcern) -> Self
[src]
The write concern for the operation.
pub async fn query(
self,
client: &Client,
documents: Vec<C>
) -> Result<HashMap<usize, Bson>, Error> where
C: Collection,
[src]
self,
client: &Client,
documents: Vec<C>
) -> Result<HashMap<usize, Bson>, Error> where
C: Collection,
Query the database with this querier.
Errors
This method fails if:
- any of the documents could not be converted into a BSON
Document
. - the mongodb encountered an error.
pub fn blocking(
self,
client: &Client,
documents: Vec<C>
) -> Result<HashMap<usize, Bson>, Error> where
C: Collection,
[src]
self,
client: &Client,
documents: Vec<C>
) -> Result<HashMap<usize, Bson>, Error> where
C: Collection,
Trait Implementations
impl<C: Clone + Collection> Clone for Insert<C>
[src]
impl<C: Collection> Default for Insert<C>
[src]
Auto Trait Implementations
impl<C> RefUnwindSafe for Insert<C> where
C: RefUnwindSafe,
C: RefUnwindSafe,
impl<C> Send for Insert<C> where
C: Send,
C: Send,
impl<C> Sync for Insert<C> where
C: Sync,
C: Sync,
impl<C> Unpin for Insert<C> where
C: Unpin,
C: Unpin,
impl<C> UnwindSafe for Insert<C> where
C: UnwindSafe,
C: UnwindSafe,
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>,