Click or drag to resize

Database Class

A Couchbase Lite database. This class is responsible for CRUD operations revolving around Document instances. It is portable between platforms if the file is retrieved, and can be seeded with prepopulated data if desired.
Inheritance Hierarchy
SystemObject
  Couchbase.LiteDatabase

Namespace:  Couchbase.Lite
Assembly:  Couchbase.Lite (in Couchbase.Lite.dll) Version: 2.0.0-b0713
Syntax
C#
public sealed class Database : IDisposable

The Database type exposes the following members.

Constructors
  NameDescription
Public methodDatabase
Creates a database with a given name and database configuration. If the configuration is null then the default configuration will be used. If the database does not yet exist, it will be created.
Top
Properties
  NameDescription
Public propertyConfig
Gets the configuration that was used to create the database. The returned object is readonly; an InvalidOperationException will be thrown if the configuration object is modified.
Public propertyCount
Gets the number of documents in the database
Public propertyItem
Gets a DocumentFragment with the given document ID
Public propertyName
Gets the database's name
Public propertyPath
Gets the database's path. If the database is closed or deleted, a null value will be returned.
Top
Methods
  NameDescription
Public methodAddChangeListener(EventHandlerDatabaseChangedEventArgs)
Adds a change listener for the changes that occur in this database. Signatures are the same as += style event handlers. The callback will be invoked on a thread pool thread.
Public methodAddChangeListener(TaskScheduler, EventHandlerDatabaseChangedEventArgs)
Adds a change listener for the changes that occur in this database. Signatures are the same as += style event handlers, but the callbacks will be called using the specified TaskScheduler. If the scheduler is null, the default task scheduler will be used (scheduled via thread pool).
Public methodAddDocumentChangeListener(String, EventHandlerDocumentChangedEventArgs)
Adds a document change listener for the document with the given ID. The callback will be invoked on a thread pool thread.
Public methodAddDocumentChangeListener(String, TaskScheduler, EventHandlerDocumentChangedEventArgs)
Adds a document change listener for the document with the given ID and the TaskScheduler that will be used to invoke the callback. If the scheduler is not specified, then the default scheduler will be used (scheduled via thread pool)
Public methodClose
Closes the database
Public methodCompact
Compacts the database file by deleting unused attachment files and vacuuming the SQLite database
Public methodStatic memberCopy
Copies a canned database from the given path to a new database with the given name and the configuration. The new database will be created at the directory specified in the configuration. Without given the database configuration, the default configuration that is equivalent to setting all properties in the configuration to null wlil be used.
Public methodCreateIndex
Creates an index which could be a value index from ValueIndex(IValueIndexItem) or a full-text search index from FullTextIndex(IFullTextIndexItem) with the given name. The name can be used for deleting the index. Creating a new different index with an existing index name will replace the old index; creating the same index with the same name will be no-ops.
Public methodDelete
Deletes a database
Public methodDelete(Document)
Deletes a document from the database. When write operations are executed concurrently, the last writer will overwrite all other written values. Calling this method is the same as calling Delete(Document, ConcurrencyControl) with LastWriteWins
Public methodStatic memberDelete(String, String)
Deletes a database of the given name in the given directory. If a null directory is passed then the default directory is searched.
Public methodDelete(Document, ConcurrencyControl)
Deletes the given Document from this database
Public methodDeleteIndex
Deletes the index with the given name
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Overrides ObjectEquals(Object).)
Public methodStatic memberExists
Checks whether a database of the given name exists in the given directory or not. If a null directory is passed then the default directory is checked
Protected methodFinalize
Finalizer
(Overrides ObjectFinalize.)
Public methodGetDocument
Gets the Document with the specified ID
Public methodGetHashCode
Serves as the default hash function.
(Overrides ObjectGetHashCode.)
Public methodGetIndexes
Gets a list of index names that are present in the database
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInBatch
Runs the given batch of operations as an atomic unit
Public methodPurge
Purges the given Document from the database. This leaves no trace behind and will not be replicated
Public methodRemoveChangeListener
Removes a database changed listener by token
Public methodSave(MutableDocument)
Saves the given MutableDocument into this database. This call is equivalent to calling Save(MutableDocument, ConcurrencyControl) with a second argument of LastWriteWins
Public methodSave(MutableDocument, ConcurrencyControl)
Saves the given MutableDocument into this database
Public methodStatic memberSetLogLevel
Sets the log level for the given domains(s)
Public methodToString
Returns a string that represents the current object.
(Overrides ObjectToString.)
Top
See Also