Class Database
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 pre-populated data if desired.
Inheritance
Implements
Inherited Members
Namespace: Couchbase.Lite
Assembly: Couchbase.Lite.dll
Syntax
public sealed class Database : IChangeObservable<DatabaseChangedEventArgs>, IDocumentChangeObservable, IChangeObservableRemovable, IDisposable
Constructors
| Improve this Doc View SourceDatabase(String, DatabaseConfiguration)
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.
Declaration
public Database(string name, DatabaseConfiguration configuration = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the database |
DatabaseConfiguration | configuration | The database configuration, or |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
CouchbaseLiteException | Thrown with CantOpenFile if the
directory indicated in |
CouchbaseException | Thrown if an error condition was returned by LiteCore |
Properties
| Improve this Doc View SourceConfig
Gets the configuration that was used to create the database. The returned object is readonly; an System.InvalidOperationException will be thrown if the configuration object is modified.
Declaration
public DatabaseConfiguration Config { get; }
Property Value
Type | Description |
---|---|
DatabaseConfiguration |
Count
[DEPRECATED] Gets the number of documents in the database
Declaration
[Obsolete("Count is deprecated, please use GetDefaultCollection().Count")]
public ulong Count { get; }
Property Value
Type | Description |
---|---|
System.UInt64 |
Item[String]
[DEPRECATED] Gets a DocumentFragment with the given document ID
Declaration
[Obsolete("Document subscript in the Database class is deprecated, please use Document Script of the default collection.")]
public DocumentFragment this[string id] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | id | The ID of the DocumentFragment to retrieve |
Property Value
Type | Description |
---|---|
DocumentFragment | The DocumentFragment object |
Log
Gets the object that stores the available logging methods for Couchbase Lite
Declaration
public static Log Log { get; }
Property Value
Type | Description |
---|---|
Log |
Name
Gets the database's name
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
Path
Gets the database's path. If the database is closed or deleted, a null
value will be returned.
Declaration
public string Path { get; }
Property Value
Type | Description |
---|---|
System.String |
Prediction
Gets the prediction manager that stores predictive models
Declaration
public static Prediction Prediction { get; }
Property Value
Type | Description |
---|---|
Prediction |
Remarks
NOTE: This is an enterprise edition feature
Methods
| Improve this Doc View SourceAddChangeListener(EventHandler<DatabaseChangedEventArgs>)
[DEPRECATED] Adds a change listener for the changes that occur in the default collection of this database. Signatures are the same as += style event handlers. The callback will be invoked on a thread pool thread.
Declaration
[Obsolete("AddChangeListener is deprecated, please use GetDefaultCollection().AddChangeListener")]
public ListenerToken AddChangeListener(EventHandler<DatabaseChangedEventArgs> handler)
Parameters
Type | Name | Description |
---|---|---|
System.EventHandler<DatabaseChangedEventArgs> | handler | The handler to invoke |
Returns
Type | Description |
---|---|
ListenerToken | A ListenerToken that can be used to remove the handler later |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
AddChangeListener(TaskScheduler, EventHandler<DatabaseChangedEventArgs>)
[DEPRECATED] Adds a change listener for the changes that occur in the default collection of this database. Signatures are the same as += style event handlers, but the callbacks will be called using the specified System.Threading.Tasks.TaskScheduler. If the scheduler is null, the default task scheduler will be used (scheduled via thread pool).
Declaration
[Obsolete("AddChangeListener is deprecated, please use GetDefaultCollection().AddChangeListener")]
public ListenerToken AddChangeListener(TaskScheduler scheduler, EventHandler<DatabaseChangedEventArgs> handler)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.Tasks.TaskScheduler | scheduler | The scheduler to use when firing the change handler |
System.EventHandler<DatabaseChangedEventArgs> | handler | The handler to invoke |
Returns
Type | Description |
---|---|
ListenerToken | A ListenerToken that can be used to remove the handler later |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
AddDocumentChangeListener(String, EventHandler<DocumentChangedEventArgs>)
[DEPRECATED] Adds a document change listener for the document with the given ID. The callback will be invoked on a thread pool thread.
Declaration
[Obsolete("AddDocumentChangeListener is deprecated, please use GetDefaultCollection().AddDocumentChangeListener")]
public ListenerToken AddDocumentChangeListener(string id, EventHandler<DocumentChangedEventArgs> handler)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | The document ID |
System.EventHandler<DocumentChangedEventArgs> | handler | The logic to handle the event |
Returns
Type | Description |
---|---|
ListenerToken | A ListenerToken that can be used to remove the listener later |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
AddDocumentChangeListener(String, TaskScheduler, EventHandler<DocumentChangedEventArgs>)
[DEPRECATED] Adds a document change listener for the document with the given ID and the System.Threading.Tasks.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)
Declaration
[Obsolete("AddDocumentChangeListener is deprecated, please use GetDefaultCollection().AddDocumentChangeListener")]
public ListenerToken AddDocumentChangeListener(string id, TaskScheduler scheduler, EventHandler<DocumentChangedEventArgs> handler)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | The document ID |
System.Threading.Tasks.TaskScheduler | scheduler | The scheduler to use when firing the event handler |
System.EventHandler<DocumentChangedEventArgs> | handler | The logic to handle the event |
Returns
Type | Description |
---|---|
ListenerToken | A ListenerToken that can be used to remove the listener later |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
ChangeEncryptionKey(EncryptionKey)
Sets the encryption key for the database. If null, encryption is removed.
Declaration
public void ChangeEncryptionKey(EncryptionKey key)
Parameters
Type | Name | Description |
---|---|---|
EncryptionKey | key | The new key to encrypt the database with, or |
Remarks
NOTE: This is an enterprise edition feature
Close()
Close database synchronously. Before closing the database, the active replicators, listeners and live queries will be stopped.
Declaration
public void Close()
Exceptions
Type | Condition |
---|---|
CouchbaseLiteException | Thrown with LiteCore.Interop.C4ErrorCode.Busy if there are still active replicators or query listeners when the close call occurred |
Copy(String, String, DatabaseConfiguration)
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
will be used.
Declaration
public static void Copy(string path, string name, DatabaseConfiguration config)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The source database path (i.e. path to the cblite2 folder) |
System.String | name | The name of the new database to be created |
DatabaseConfiguration | config | The database configuration for the new database |
Remarks
Note: This method will copy the database without changing the encryption key of the original database: the encryption key specified in the given config is the encryption key used for both the original and copied database.To change or add the encryption key for the copied database, call ChangeEncryptionKey(EncryptionKey) for the copy. Furthermore, any Database object that is operating on the source database to be copied should be closed before this call to eliminate the possibility on some platforms of a "resource in use" error.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
CouchbaseException | Thrown if an error condition is returned from LiteCore |
CreateCollection(String, String)
Create a named collection in the specified scope. If the collection already exists, the existing collection will be returned.
Declaration
public Collection CreateCollection(string name, string scope = "_default")
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the new collection to be created |
System.String | scope | The scope of the new collection to be created |
Returns
Type | Description |
---|---|
Collection | New collection with the given name and scope |
Remarks
None default Collection and Scope Names are allowed to contain the following characters A - Z, a - z, 0 - 9, and the symbols , -, and % and to start with A-Z, a-z, 0-9, and - None default Collection and Scope Names start with and % are prohibited
Exceptions
Type | Condition |
---|---|
CouchbaseException | Thrown if an error condition is returned from LiteCore |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
CreateIndex(String, IndexConfiguration)
[DEPRECATED] Creates a SQL++ query index which could be a value index from ValueIndexConfiguration or a full-text search index from FullTextIndexConfiguration 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.
Declaration
[Obsolete("CreateIndex is deprecated, please use GetDefaultCollection().CreateIndex")]
public void CreateIndex(string name, IndexConfiguration indexConfig)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The index name |
IndexConfiguration | indexConfig | The index |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
CouchbaseException | Thrown if an error condition is returned from LiteCore |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
System.NotSupportedException | Thrown if an implementation of IIndex other than one of the library provided ones is used |
CreateIndex(String, IIndex)
[DEPRECATED] 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.
Declaration
[Obsolete("CreateIndex is deprecated, please use GetDefaultCollection().CreateIndex")]
public void CreateIndex(string name, IIndex index)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The index name |
IIndex | index | The index |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
CouchbaseException | Thrown if an error condition is returned from LiteCore |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
System.NotSupportedException | Thrown if an implementation of IIndex other than one of the library provided ones is used |
CreateQuery(String)
Creates a Query object from the given SQL++ string.
Declaration
public IQuery CreateQuery(string queryExpression)
Parameters
Type | Name | Description |
---|---|---|
System.String | queryExpression | SQL++ Expression |
Returns
Type | Description |
---|---|
IQuery |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
CouchbaseException | Thrown if an error condition is returned from LiteCore |
CouchbaseLiteException | Throw if compiling |
Delete()
Close and delete the database synchronously. Before closing the database, the active replicators, listeners and live queries will be stopped.
Declaration
public void Delete()
Exceptions
Type | Condition |
---|---|
CouchbaseException | Thrown if an error condition is returned from LiteCore |
CouchbaseLiteException | Thrown with LiteCore.Interop.C4ErrorCode.Busy if there are still active replicators or query listeners when the close call occurred |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
Delete(Document)
[DEPRECATED] 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
Declaration
[Obsolete("Delete is deprecated, please use GetDefaultCollection().Delete")]
public void Delete(Document document)
Parameters
Type | Name | Description |
---|---|---|
Document | document | The document |
Exceptions
Type | Condition |
---|---|
CouchbaseException | Thrown if an error condition is returned from LiteCore |
CouchbaseLiteException | Thrown with LiteCore.Interop.C4ErrorCode.InvalidParameter when trying to save a document into a database other than the one it was previously added to |
CouchbaseLiteException | Thrown with LiteCore.Interop.C4ErrorCode.NotFound when trying to delete a document that hasn't been saved into a Database yet |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
Delete(Document, ConcurrencyControl)
[DEPRECATED] Deletes the given Document from this database
Declaration
[Obsolete("Delete is deprecated, please use GetDefaultCollection().Delete")]
public bool Delete(Document document, ConcurrencyControl concurrencyControl)
Parameters
Type | Name | Description |
---|---|---|
Document | document | The document to save |
ConcurrencyControl | concurrencyControl | The rule to use when encountering a conflict in the database |
Returns
Type | Description |
---|---|
System.Boolean |
|
Exceptions
Type | Condition |
---|---|
CouchbaseException | Thrown if an error condition is returned from LiteCore |
CouchbaseLiteException | Thrown with LiteCore.Interop.C4ErrorCode.InvalidParameter when trying to save a document into a database other than the one it was previously added to |
CouchbaseLiteException | Thrown with LiteCore.Interop.C4ErrorCode.NotFound when trying to delete a document that hasn't been saved into a Database yet |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
Delete(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.
Declaration
public static void Delete(string name, string directory)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The database name |
System.String | directory | The directory where the database is located, or |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
CouchbaseException | Thrown if an error condition is returned from LiteCore |
DeleteCollection(String, String)
Delete a collection by name in the specified scope. If the collection doesn't exist, the operation will be no-ops.
Declaration
public void DeleteCollection(string name, string scope = "_default")
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the collection to be deleted |
System.String | scope | The scope of the collection to be deleted |
Exceptions
Type | Condition |
---|---|
CouchbaseException | Thrown if an error condition is returned from LiteCore |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
DeleteIndex(String)
[DEPRECATED] Deletes the index with the given name
Declaration
[Obsolete("DeleteIndex is deprecated, please use GetDefaultCollection().DeleteIndex")]
public void DeleteIndex(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the index to delete |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
Exists(String, String)
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
Declaration
public static bool Exists(string name, string directory)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The database name |
System.String | directory | The directory where the database is located |
Returns
Type | Description |
---|---|
System.Boolean |
|
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
CouchbaseException | Thrown if an error condition is returned from LiteCore |
Finalize()
Finalizer
Declaration
protected void Finalize()
GetBlob(Dictionary<String, Object>)
Gets the Blob of a given blob dictionary.
Declaration
public Blob GetBlob(Dictionary<string, object> blobDict)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<System.String, System.Object> | blobDict | JSON Dictionary represents in the Blob and the value will be validated in IsBlob(IDictionary<String, Object>) |
Returns
Type | Description |
---|---|
Blob | The contained value, or |
Remarks
The blobs that are not associated with any documents are/will be removed from the database after compacting the database.
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Throw if the given blob dictionary is not valid. |
GetCollection(String, String)
Get a collection in the specified scope by name. If the collection doesn't exist, null will be returned. Note that this will cache after the first retrieval and return the same instance until said instance is disposed. Be careful if using multiple instances because disposing one will invalidate them all.
Declaration
public Collection GetCollection(string name, string scope = "_default")
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the collection |
System.String | scope | The scope of the collection |
Returns
Type | Description |
---|---|
Collection | The collection with the given name and scope |
Exceptions
Type | Condition |
---|---|
CouchbaseException | Thrown if an error condition is returned from LiteCore |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
GetCollections(String)
Get all collections of given Scope name.
Declaration
public IReadOnlyList<Collection> GetCollections(string scope = "_default")
Parameters
Type | Name | Description |
---|---|---|
System.String | scope | The scope of the collections belong to |
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<Collection> | All collections with the given scope name |
Exceptions
Type | Condition |
---|---|
CouchbaseException | Thrown if an error condition is returned from LiteCore |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
GetDefaultCollection()
Get the default collection. This is a cached object so there is no need to dispose it. If you do, a new one will be created on the next call.
Declaration
public Collection GetDefaultCollection()
Returns
Type | Description |
---|---|
Collection | default collection |
Exceptions
Type | Condition |
---|---|
CouchbaseException | Thrown if an error condition is returned from LiteCore |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
GetDefaultScope()
Get the default scope. This is a cached object so there is no need to dispose it.
Declaration
public Scope GetDefaultScope()
Returns
Type | Description |
---|---|
Scope | default scope |
Exceptions
Type | Condition |
---|---|
CouchbaseException | Thrown if an error condition is returned from LiteCore |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
GetDocument(String)
[DEPRECATED] Gets the Document with the specified ID
Declaration
[Obsolete("GetDocument is deprecated, please use GetDefaultCollection().GetDocument")]
public Document GetDocument(string id)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | The ID to use when creating or getting the document |
Returns
Type | Description |
---|---|
Document | The instantiated document, or |
GetDocumentExpiration(String)
[DEPRECATED] Returns the expiration time of the document. null
will be returned
if there is no expiration time set
Declaration
[Obsolete("GetDocumentExpiration is deprecated, please use GetDefaultCollection().GetDocumentExpiration")]
public DateTimeOffset? GetDocumentExpiration(string docId)
Parameters
Type | Name | Description |
---|---|---|
System.String | docId | The ID of the Document |
Returns
Type | Description |
---|---|
System.Nullable<System.DateTimeOffset> | Nullable expiration timestamp as a System.DateTimeOffset
of the document or |
Exceptions
Type | Condition |
---|---|
CouchbaseLiteException | Throws NOT FOUND error if the document doesn't exist |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
GetIndexes()
[DEPRECATED] Gets a list of index names that are present in the database
Declaration
[Obsolete("GetIndexes is deprecated, please use GetDefaultCollection().GetIndexes")]
public IList<string> GetIndexes()
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<System.String> | The list of created index names |
GetScope(String)
Get a scope object by name. As the scope cannot exist by itself without having a collection, the null value will be returned if there is no collection under the given scope’s name. The default scope is an exception, it will always be returned.
Declaration
public Scope GetScope(string name = "_default")
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the scope |
Returns
Type | Description |
---|---|
Scope | scope object with the given scope name |
Exceptions
Type | Condition |
---|---|
CouchbaseException | Thrown if an error condition is returned from LiteCore |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
GetScopes()
Get scope names that have at least one collection. The default scope is an exception as it will always be listed even it doesn't contain any collection.
Declaration
public IReadOnlyList<Scope> GetScopes()
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<Scope> | scope names of all existing scopes, in the order in which they were created. |
Exceptions
Type | Condition |
---|---|
CouchbaseException | Thrown if an error condition is returned from LiteCore |
System.InvalidOperationException | Thrown if this method is called after the database is closed |
InBatch(Action)
Runs the given batch of operations as an atomic unit
Declaration
public void InBatch(Action action)
Parameters
Type | Name | Description |
---|---|---|
System.Action | action | The System.Action containing the operations. |
PerformMaintenance(MaintenanceType)
Performs database maintenance.
Declaration
public void PerformMaintenance(MaintenanceType type)
Parameters
Type | Name | Description |
---|---|---|
MaintenanceType | type | Maintenance type |
Purge(Document)
[DEPRECATED] Purges the given Document from the database. This leaves no trace behind and will not be replicated
Declaration
[Obsolete("Purge is deprecated, please use GetDefaultCollection().Purge")]
public void Purge(Document document)
Parameters
Type | Name | Description |
---|---|---|
Document | document | The document to purge |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when trying to purge a document from a database other than the one it was previously added to |
Purge(String)
[DEPRECATED] Purges the given document id of the Document from the database. This leaves no trace behind and will not be replicated
Declaration
[Obsolete("Purge is deprecated, please use GetDefaultCollection().Purge")]
public void Purge(string docId)
Parameters
Type | Name | Description |
---|---|---|
System.String | docId | The id of the document to purge |
RemoveChangeListener(ListenerToken)
[DEPRECATED] Removes a database changed listener by token
Declaration
[Obsolete("RemoveChangeListener is deprecated, please use GetDefaultCollection().RemoveChangeListener")]
public void RemoveChangeListener(ListenerToken token)
Parameters
Type | Name | Description |
---|---|---|
ListenerToken | token | The token received from AddChangeListener(TaskScheduler, EventHandler<DatabaseChangedEventArgs>) and family |
Save(MutableDocument)
[DEPRECATED] Saves the given MutableDocument into this database. This call is equivalent to calling Save(MutableDocument, ConcurrencyControl) with a second argument of LastWriteWins
Declaration
[Obsolete("Save is deprecated, please use GetDefaultCollection().Save")]
public void Save(MutableDocument document)
Parameters
Type | Name | Description |
---|---|---|
MutableDocument | document | The document to save |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when trying to save a document into a database other than the one it was previously added to |
Save(MutableDocument, ConcurrencyControl)
[DEPRECATED] Saves the given MutableDocument into this database
Declaration
[Obsolete("Save is deprecated, please use GetDefaultCollection().Save")]
public bool Save(MutableDocument document, ConcurrencyControl concurrencyControl)
Parameters
Type | Name | Description |
---|---|---|
MutableDocument | document | The document to save |
ConcurrencyControl | concurrencyControl | The rule to use when encountering a conflict in the database |
Returns
Type | Description |
---|---|
System.Boolean |
|
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when trying to save a document into a database other than the one it was previously added to |
Save(MutableDocument, Func<MutableDocument, Document, Boolean>)
[DEPRECATED] Saves a document to the database. When write operations are executed concurrently, and if conflicts occur, conflict handler will be called. Use the handler to directly edit the document.Returning true, will save the document. Returning false, will cancel the save operation.
Declaration
[Obsolete("Save is deprecated, please use GetDefaultCollection().Save")]
public bool Save(MutableDocument document, Func<MutableDocument, Document, bool> conflictHandler)
Parameters
Type | Name | Description |
---|---|---|
MutableDocument | document | The document to save |
System.Func<MutableDocument, Document, System.Boolean> | conflictHandler | The conflict handler block which can be used to resolve it. |
Returns
Type | Description |
---|---|
System.Boolean |
|
SaveBlob(Blob)
Save a blob object directly into the database without associating it with any documents.
Declaration
public void SaveBlob(Blob blob)
Parameters
Type | Name | Description |
---|---|---|
Blob | blob | The blob object will be saved into Database. |
Remarks
The blobs that are not associated with any documents will be removed from the database when compacting the database.
Exceptions
Type | Condition |
---|---|
CouchbaseLiteException | Thrown if an error occurs during the blob save operation. |
SetDocumentExpiration(String, Nullable<DateTimeOffset>)
[DEPRECATED] Sets an expiration date on a document. After this time, the document will be purged from the database.
Declaration
[Obsolete("SetDocumentExpiration is deprecated, please use GetDefaultCollection().SetDocumentExpiration")]
public bool SetDocumentExpiration(string docId, DateTimeOffset? expiration)
Parameters
Type | Name | Description |
---|---|---|
System.String | docId | The ID of the Document |
System.Nullable<System.DateTimeOffset> | expiration | Nullable expiration timestamp as a
System.DateTimeOffset, set timestamp to |
Returns
Type | Description |
---|---|
System.Boolean | Whether successfully sets an expiration date on the document |
Exceptions
Type | Condition |
---|---|
CouchbaseLiteException | Throws NOT FOUND error if the document doesn't exist |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |