Database

Struct Database 

Source
pub struct Database { /* private fields */ }
Expand description

A connection to a couchbase-lite database.

Implementations§

Source§

impl Database

Source

pub fn open_named(name: &str, cfg: DatabaseConfig<'_>) -> Result<Self, Error>

Source

pub fn open_with_flags(path: &Path, flags: DatabaseFlags) -> Result<Self, Error>

Source

pub fn transaction<'a>(&'a mut self) -> Result<Transaction<'a>, Error>

Begin a new transaction, the transaction defaults to rolling back when it is dropped. If you want the transaction to commit, you must call Transaction::commit

Source

pub fn document_count(&self) -> u64

Returns the number of (undeleted) documents in the database

Source

pub fn get_existing(&self, doc_id: &str) -> Result<Document, Error>

Return existing document from database

Source

pub fn query<'a>(&'a self, query_json: &str) -> Result<Query<'a>, Error>

Compiles a query from an expression given as JSON. The expression is a predicate that describes which documents should be returned. A separate, optional sort expression describes the ordering of the results.

Source

pub fn n1ql_query<'a>(&'a self, query: &str) -> Result<Query<'a>, Error>

Compiles a query from an expression given as N1QL.

Source

pub fn enumerate_all_docs<'a>( &'a self, flags: DocEnumeratorFlags, ) -> Result<DocEnumerator<'a>, Error>

Creates an enumerator ordered by docID.

Source

pub fn register_observer<F>(&mut self, callback_f: F) -> Result<(), Error>
where F: FnMut() + Send + 'static,

Register a database observer, with a callback that will be invoked after the database changes. The callback will be called once, after the first change. After that it won’t be called again until all of the changes have been read by calling Database::observed_changes.

Source

pub fn clear_observers(&mut self)

Remove all database observers

Source

pub fn observed_changes<'a>(&'a mut self) -> ObserverdChangesIter<'a>

Get observed changes for this database

Source

pub fn init_socket_impl(handle: Handle)

Intialize socket implementation for replication (builtin couchbase-lite websocket library)

Source

pub fn shared_encoder_session(&mut self) -> Result<FlEncoderSession, Error>

Get shared “fleece” encoder, &mut self to make possible exists only one session

Source

pub fn get_indexes( &self, ) -> Result<impl FallibleStreamingIterator<Item = IndexInfo, Error = Error>, Error>

Returns the names of all indexes in the database

Source

pub fn create_index( &mut self, index_name: &str, expression_json: &str, index_type: IndexType, index_options: Option<IndexOptions<'_>>, ) -> Result<(), Error>

Creates a database index, of the values of specific expressions across all documents. The name is used to identify the index for later updating or deletion; if an index with the same name already exists, it will be replaced unless it has the exact same expressions. Note: If some documents are missing the values to be indexed, those documents will just be omitted from the index. It’s not an error.

Source

pub fn name(&self) -> Result<&str, Error>

Returns the name of the database, as given to c4db_openNamed. This is the filename without the “.cblite2” extension.

Trait Implementations§

Source§

impl Drop for Database

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V