[][src]Struct ledb::Collection

pub struct Collection(_);

Collection of documents

Implementations

impl Collection[src]

pub fn name(&self) -> &str[src]

pub fn insert<T: Serialize + Document>(&self, doc: T) -> Result<Primary>[src]

Insert document into collection

The primary key/identifier of document will be selected by auto incrementing the id of last inserted document.

Primary key/identifier of new inserted document will be returned.

pub fn find<T: DeserializeOwned + Document>(
    &self,
    filter: Option<Filter>,
    order: Order
) -> Result<DocumentsIterator<T>>
[src]

Find documents using optional filter and ordering

When none filter specified then all documents will be found.

Iterator across found documents will be returned.

You can use DocumentsIterator::len() for getting the total number of found documents.

pub fn find_all<T: DeserializeOwned + Document>(
    &self,
    filter: Option<Filter>,
    order: Order
) -> Result<Vec<T>>
[src]

Find documents using optional filter and ordering

When none filter specified then all documents will be found.

The vector with found documents will be returned.

pub fn find_ids(&self, filter: Option<Filter>) -> Result<HashSet<Primary>>[src]

pub fn update(&self, filter: Option<Filter>, modify: Modify) -> Result<usize>[src]

Update documents using optional filter and modifier

Note: When none filter specified then all documents will be modified.

Returns the number of affected documents.

pub fn remove(&self, filter: Option<Filter>) -> Result<usize>[src]

Remove documents using optional filter

Note: When none filter specified then all documents will be removed.

Returns the number of affected documents.

pub fn dump<T: DeserializeOwned + Document>(
    &self
) -> Result<DocumentsIterator<T>>
[src]

Dump all documents which stored into the collection

pub fn load<T: Serialize + Document, I>(&self, docs: I) -> Result<usize> where
    I: IntoIterator<Item = T>, 
[src]

Load new documents into the collection

Note: The old documents will be removed.

pub fn purge(&self) -> Result<()>[src]

Remove all documents from the collection

pub fn has(&self, id: Primary) -> Result<bool>[src]

Checks the collection contains document with specified primary key

pub fn get<T: DeserializeOwned + Document>(
    &self,
    id: Primary
) -> Result<Option<T>>
[src]

Get document from collection using primary key/identifier

pub fn put<T: Serialize + Document>(&self, doc: T) -> Result<()>[src]

Replace document in the collection

Note: The document must have primary key/identifier.

pub fn delete(&self, id: Primary) -> Result<bool>[src]

Delete document with specified primary key/identifier from the collection

pub fn last_id(&self) -> Result<Primary>[src]

Get the last primary key/identifier of inserted document

pub fn new_id(&self) -> Result<Primary>[src]

Get the new primary key/identifier

pub fn get_indexes(&self) -> Result<KeyFields>[src]

Get indexes info from the collection

pub fn set_indexes<T, I: AsRef<[T]>>(&self, indexes: I) -> Result<()> where
    T: Clone,
    KeyField: From<T>, 
[src]

Set indexes of collection

This method overrides collection indexes

pub fn index<T: Document>(&self) -> Result<()>[src]

Set indexes using document type

This method overrides collection indexes

pub fn ensure_index<P: AsRef<str>>(
    &self,
    path: P,
    kind: IndexKind,
    key: KeyType
) -> Result<bool>
[src]

Ensure index for the collection

pub fn has_index<P: AsRef<str>>(&self, path: P) -> Result<bool>[src]

Checks the index for specified field exists for the collection

pub fn create_index<P: AsRef<str>>(
    &self,
    path: P,
    kind: IndexKind,
    key: KeyType
) -> Result<bool>
[src]

Create index for the collection

pub fn drop_index<P: AsRef<str>>(&self, path: P) -> Result<bool>[src]

Remove index from the collection

Methods from Deref<Target = Database<'static>>

pub fn env(&self) -> &Environment[src]

Returns a reference to the Environment to which this Database belongs.

This can be used to elide needing to pass both an &Environment and an &Database around, but is also useful for the use-case wherein the Database owns the Environment.

Because this may borrow an Environment owned by this Database, the lifetime of the returned reference is dependent on self rather than being 'env. (In fact, 'env is usually 'static if the Environment is owned by the Database, so returning &'env Environment is impossible anyway.)

Example

let env: lmdb::Environment = create_env();
// We only want one `Database`, so don't bother keeping both variables
// around and instead let the `Database` own the `Environment`.
let db = lmdb::Database::open(
  env, None, &lmdb::DatabaseOptions::defaults()).unwrap();

// `env` has been consumed, but we can still do useful things by
// getting a reference to the inner value.
let txn = lmdb::ReadTransaction::new(db.env()).unwrap();

// Do stuff with `txn`, etc.

pub fn assert_same_env(&self, other_env: &Environment) -> Result<(), Error>[src]

Checks that other_env is the same as the environment on this Database.

If it matches, returns Ok(()); otherwise, returns Err.

pub fn dbi(&self) -> u32[src]

👎 Deprecated since 0.4.4:

use as_raw() instead

Returns the underlying integer handle for this database.

Deprecated

Renamed to as_raw() for consistency.

pub fn as_raw(&self) -> u32[src]

Returns the underlying integer handle for this database.

Trait Implementations

impl Clone for Collection[src]

impl ConstDeref for Collection[src]

type Target = Database<'static>

The type this value dereferences to.

impl Deref for Collection[src]

type Target = Database<'static>

The resulting type after dereferencing.

impl Drop for Collection[src]

impl<'a> Into<Supercow<'a, Database<'a>, Database<'a>, Box<dyn DefaultFeatures<'static> + 'static>, BoxedStorage, *const Database<'a>>> for Collection[src]

Auto Trait Implementations

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<'a, T> DefaultFeatures<'a> for T where
    T: 'a + Clone + Send + Sync
[src]

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

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

impl<'a, T> NonSyncFeatures<'a> for T where
    T: 'a + Clone
[src]

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

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.