Struct mongodm::index::Index [−][src]
pub struct Index { /* fields omitted */ }
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]
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 RefUnwindSafe for Index
impl UnwindSafe for Index
impl UnwindSafe for Index
Blanket Implementations
impl<T> Instrument 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> Instrument 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> Same<T> for T
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,