[−][src]Struct mongodm::index::Index
Specify field to be used for indexing and options.
Example
use mongodm::{Index, SortOrder, IndexOption, mongo::bson::doc}; let index = Index::new_with_direction("username", SortOrder::Descending) .with_key("last_seen") // compound with last_seen .with_option(IndexOption::Unique); let doc = index.into_document(); assert_eq!( doc, doc! { "key": { "username": -1, "last_seen": 1 }, "unique": true, "name": "username_-1_last_seen_1", } )
Implementations
impl Index
[src]
pub fn new(key: impl Into<Cow<'static, str>>) -> Self
[src]
Make a new index for the given key with ascending direction.
pub fn new_with_direction(
key: impl Into<Cow<'static, str>>,
direction: SortOrder
) -> Self
[src]
key: impl Into<Cow<'static, str>>,
direction: SortOrder
) -> Self
Make a new index for the given key with a direction.
pub fn add_key(&mut self, key: impl Into<Cow<'static, str>>)
[src]
Make this index compound adding the given key with ascending direction.
pub fn with_key(self, key: impl Into<Cow<'static, str>>) -> Self
[src]
Builder style method for add_key
.
pub fn add_key_with_direction(
&mut self,
key: impl Into<Cow<'static, str>>,
direction: SortOrder
)
[src]
&mut self,
key: impl Into<Cow<'static, str>>,
direction: SortOrder
)
Make this index compound adding the given key with a direction.
pub fn with_key_with_direction(
self,
key: impl Into<Cow<'static, str>>,
direction: SortOrder
) -> Self
[src]
self,
key: impl Into<Cow<'static, str>>,
direction: SortOrder
) -> Self
Builder style method for add_key_with_direction
.
pub fn add_option(&mut self, option: IndexOption)
[src]
Add an option to this index.
pub fn with_option(self, option: IndexOption) -> Self
[src]
Builder style method for add_option
.
pub fn into_document(self) -> Document
[src]
Convert this structure into a Document
version structured as expected by mongo.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Index
impl Send for Index
impl Sync for Index
impl Unpin for Index
impl UnwindSafe for Index
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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[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.
fn to_owned(&self) -> T
[src]
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.
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.
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>,