[−][src]Struct ledb::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]
&self,
filter: Option<Filter>,
order: Order
) -> Result<DocumentsIterator<T>>
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]
&self,
filter: Option<Filter>,
order: Order
) -> Result<Vec<T>>
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]
&self
) -> Result<DocumentsIterator<T>>
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]
I: IntoIterator<Item = T>,
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]
&self,
id: Primary
) -> Result<Option<T>>
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]
T: Clone,
KeyField: From<T>,
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]
&self,
path: P,
kind: IndexKind,
key: KeyType
) -> Result<bool>
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]
&self,
path: P,
kind: IndexKind,
key: KeyType
) -> Result<bool>
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]
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]
fn clone(&self) -> Collection
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl ConstDeref for Collection
[src]
type Target = Database<'static>
The type this value dereferences to.
fn const_deref(&self) -> &Self::Target
[src]
impl Deref for Collection
[src]
type Target = Database<'static>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
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
impl !RefUnwindSafe for Collection
impl Send for Collection
impl Sync for Collection
impl Unpin for Collection
impl !UnwindSafe for Collection
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<'a, T> DefaultFeatures<'a> for T where
T: 'a + Clone + Send + Sync,
[src]
T: 'a + Clone + Send + Sync,
fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a> + 'a>
[src]
fn self_address_mut(&mut self) -> *mut ()
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<'a, T> NonSyncFeatures<'a> for T where
T: 'a + Clone,
[src]
T: 'a + Clone,
fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a> + 'a>
[src]
fn self_address_mut(&mut self) -> *mut ()
[src]
impl<T> SafeBorrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_replacement(ptr: &T) -> &T
[src]
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>,