Struct mongodm::index::Index[][src]

pub struct Index { /* fields omitted */ }

Specify field to be used for indexing and options.

Mongo manual

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.

Mongo manual

pub fn new_with_direction(
    key: impl Into<Cow<'static, str>>,
    direction: SortOrder
) -> Self
[src]

Make a new index for the given key with a direction.

Mongo manual

pub fn add_key(&mut self, key: impl Into<Cow<'static, str>>)[src]

Make this index compound adding the given key with ascending direction.

Mongo manual.

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]

Make this index compound adding the given key with a direction.

Mongo manual.

pub fn with_key_with_direction(
    self,
    key: impl Into<Cow<'static, str>>,
    direction: SortOrder
) -> Self
[src]

Builder style method for add_key_with_direction.

pub fn add_option(&mut self, option: IndexOption)[src]

Add an option to this index.

Mongo manual

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

impl Clone for Index[src]

impl Debug for Index[src]

impl Default for Index[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,