Class Collection
Inheritance
Implements
Inherited Members
Namespace: Couchbase.Lite
Assembly: Couchbase.Lite.dll
Syntax
public sealed class Collection : IChangeObservable<CollectionChangedEventArgs>, IDocumentChangeObservable, IChangeObservableRemovable, IDisposable
Fields
| Improve this Doc View SourceDefaultCollectionName
Declaration
public static readonly string DefaultCollectionName
Field Value
Type | Description |
---|---|
System. |
DefaultScopeName
Declaration
public static readonly string DefaultScopeName
Field Value
Type | Description |
---|---|
System. |
Properties
| Improve this Doc View SourceCount
Gets the total documents in the Collection
Declaration
public ulong Count { get; }
Property Value
Type | Description |
---|---|
System. |
Item[String]
Gets a Document
Declaration
public DocumentFragment this[string id] { get; }
Parameters
Type | Name | Description |
---|---|---|
System. |
id | The ID of the Document |
Property Value
Type | Description |
---|---|
Document |
The Document |
Name
Gets the Collection Name
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System. |
Remarks
Naming rules: Must be between 1 and 251 characters in length. Can only contain the characters A-Z, a-z, 0-9, and the symbols , -, and %. Cannot start with or %. Case sensitive.
Scope
Gets the Scope of the Collection belongs to
Declaration
public Scope Scope { get; }
Property Value
Type | Description |
---|---|
Scope |
Methods
| Improve this Doc View SourceAddChangeListener(EventHandler<CollectionChangedEventArgs>)
Adds a change listener for the changes that occur in this collection. Signatures are the same as += style event handlers. The callback will be invoked on a thread pool thread.
Declaration
public ListenerToken AddChangeListener(EventHandler<CollectionChangedEventArgs> handler)
Parameters
Type | Name | Description |
---|---|---|
System. |
handler | The handler to invoke |
Returns
Type | Description |
---|---|
Listener |
A Listener |
Exceptions
Type | Condition |
---|---|
System. |
Thrown if |
System. |
Thrown if this method is called after the database is closed |
AddChangeListener(TaskScheduler, EventHandler<CollectionChangedEventArgs>)
Adds a change listener for the changes that occur in this collection. Signatures
are the same as += style event handlers, but the callbacks will be called using the
specified System.
Declaration
public ListenerToken AddChangeListener(TaskScheduler scheduler, EventHandler<CollectionChangedEventArgs> handler)
Parameters
Type | Name | Description |
---|---|---|
System. |
scheduler | The scheduler to use when firing the change handler |
System. |
handler | The handler to invoke |
Returns
Type | Description |
---|---|
Listener |
A Listener |
Exceptions
Type | Condition |
---|---|
System. |
Thrown if |
System. |
Thrown if this method is called after the database is closed |
AddDocumentChangeListener(String, EventHandler<DocumentChangedEventArgs>)
Adds a document change listener for the document with the given ID. The callback will be invoked on a thread pool thread.
Declaration
public ListenerToken AddDocumentChangeListener(string id, EventHandler<DocumentChangedEventArgs> handler)
Parameters
Type | Name | Description |
---|---|---|
System. |
id | The document ID |
System. |
handler | The logic to handle the event |
Returns
Type | Description |
---|---|
Listener |
A Listener |
Exceptions
Type | Condition |
---|---|
System. |
Thrown if |
Couchbase |
Thrown with Lite |
AddDocumentChangeListener(String, TaskScheduler, EventHandler<DocumentChangedEventArgs>)
Adds a document change listener for the document with the given ID and the System.
Declaration
public ListenerToken AddDocumentChangeListener(string id, TaskScheduler scheduler, EventHandler<DocumentChangedEventArgs> handler)
Parameters
Type | Name | Description |
---|---|---|
System. |
id | The document ID |
System. |
scheduler | The scheduler to use when firing the event handler |
System. |
handler | The logic to handle the event |
Returns
Type | Description |
---|---|
Listener |
A Listener |
Exceptions
Type | Condition |
---|---|
System. |
Thrown if |
Couchbase |
Thrown with Lite |
CreateIndex(String, IndexConfiguration)
Creates an index which could be a value index from Value
Declaration
public void CreateIndex(string name, IndexConfiguration indexConfig)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The index name |
Index |
indexConfig | The configuration object for the index |
Exceptions
Type | Condition |
---|---|
System. |
Thrown if |
Couchbase |
Thrown if an error condition is returned from LiteCore |
System. |
Thrown if this method is called after the collection is closed |
System. |
Thrown if an implementation of IIndex other than one of the library provided ones is used |
Couchbase |
Thrown with Lite |
CreateIndex(String, IIndex)
Creates an index which could be a value index from Value
Declaration
public void CreateIndex(string name, IIndex index)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The index name |
IIndex | index | The index |
Exceptions
Type | Condition |
---|---|
System. |
Thrown if |
Couchbase |
Thrown if an error condition is returned from LiteCore |
System. |
Thrown if this method is called after the database is closed |
System. |
Thrown if an implementation of IIndex other than one of the library provided ones is used |
Couchbase |
Thrown with Lite |
CreateQuery(String)
Declaration
public IQuery CreateQuery(string queryExpression)
Parameters
Type | Name | Description |
---|---|---|
System. |
queryExpression |
Returns
Type | Description |
---|---|
IQuery |
Delete(Document)
Deletes a document from the collection. 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, Concurrency
Declaration
public void Delete(Document document)
Parameters
Type | Name | Description |
---|---|---|
Document | document | The document |
Exceptions
Type | Condition |
---|---|
Couchbase |
Thrown if an error condition is returned from LiteCore |
Couchbase |
Thrown with Lite |
Couchbase |
Thrown with Lite |
Couchbase |
Thrown with Lite |
Delete(Document, ConcurrencyControl)
Deletes the given Document from this collection
Declaration
public bool Delete(Document document, ConcurrencyControl concurrencyControl)
Parameters
Type | Name | Description |
---|---|---|
Document | document | The document to save |
Concurrency |
concurrencyControl | The rule to use when encountering a conflict in the collection |
Returns
Type | Description |
---|---|
System. |
|
Exceptions
Type | Condition |
---|---|
Couchbase |
Thrown if an error condition is returned from LiteCore |
Couchbase |
Thrown with Lite |
Couchbase |
Thrown with Lite |
Couchbase |
Thrown with Lite |
DeleteIndex(String)
Deletes the index with the given name
Declaration
public void DeleteIndex(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The name of the index to delete |
Exceptions
Type | Condition |
---|---|
Couchbase |
Thrown with Lite |
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. |
obj |
Returns
Type | Description |
---|---|
System. |
Overrides
Finalize()
Finalizer
Declaration
protected void Finalize()
GetDocument(String)
Gets the Document with the specified ID
Declaration
public Document GetDocument(string id)
Parameters
Type | Name | Description |
---|---|---|
System. |
id | The ID to use when creating or getting the document |
Returns
Type | Description |
---|---|
Document | The instantiated document, or |
Exceptions
Type | Condition |
---|---|
Couchbase |
Thrown with Lite |
GetDocumentExpiration(String)
Returns the expiration time of the document. null
will be returned
if there is no expiration time set
Declaration
public DateTimeOffset? GetDocumentExpiration(string docId)
Parameters
Type | Name | Description |
---|---|---|
System. |
docId | The ID of the Document |
Returns
Type | Description |
---|---|
System. |
Nullable expiration timestamp as a System. |
Exceptions
Type | Condition |
---|---|
Couchbase |
Throws NOT FOUND error if the document doesn't exist |
Couchbase |
Thrown with Lite |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System. |
Overrides
GetIndexes()
Gets a list of index names that are present in the collection
Declaration
public IList<string> GetIndexes()
Returns
Type | Description |
---|---|
System. |
The list of created index names |
Exceptions
Type | Condition |
---|---|
Couchbase |
Thrown with Lite |
Purge(Document)
Purges the given Document from the collection. This leaves no trace behind and will not be replicated
Declaration
public void Purge(Document document)
Parameters
Type | Name | Description |
---|---|---|
Document | document | The document to purge |
Exceptions
Type | Condition |
---|---|
System. |
Thrown when trying to purge a document from a collection other than the one it was previously added to |
Couchbase |
Thrown with Lite |
Purge(String)
Purges the given document id of the Document from the collection. This leaves no trace behind and will not be replicated
Declaration
public void Purge(string docId)
Parameters
Type | Name | Description |
---|---|---|
System. |
docId | The id of the document to purge |
Exceptions
Type | Condition |
---|---|
Couchbase |
Thrown with Lite |
RemoveChangeListener(ListenerToken)
Removes a collection changed listener by token
Declaration
public void RemoveChangeListener(ListenerToken token)
Parameters
Type | Name | Description |
---|---|---|
Listener |
token | The token received from AddChangeListener(TaskScheduler, EventHandler<CollectionChangedEventArgs>) and family |
Exceptions
Type | Condition |
---|---|
Couchbase |
Thrown with Lite |
Save(MutableDocument)
Saves the given Mutable
Declaration
public void Save(MutableDocument document)
Parameters
Type | Name | Description |
---|---|---|
Mutable |
document | The document to save |
Exceptions
Type | Condition |
---|---|
System. |
Thrown when trying to save a document into a collection other than the one it was previously added to |
Couchbase |
Thrown with Lite |
Save(MutableDocument, ConcurrencyControl)
Saves the given Mutable
Declaration
public bool Save(MutableDocument document, ConcurrencyControl concurrencyControl)
Parameters
Type | Name | Description |
---|---|---|
Mutable |
document | The document to save |
Concurrency |
concurrencyControl | The rule to use when encountering a conflict in the collection |
Returns
Type | Description |
---|---|
System. |
|
Exceptions
Type | Condition |
---|---|
System. |
Thrown when trying to save a document into a collection other than the one it was previously added to |
Couchbase |
Thrown with Lite |
Save(MutableDocument, Func<MutableDocument, Document, Boolean>)
Saves a document to the collection. 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
public bool Save(MutableDocument document, Func<MutableDocument, Document, bool> conflictHandler)
Parameters
Type | Name | Description |
---|---|---|
Mutable |
document | The document to save |
System. |
conflictHandler | The conflict handler block which can be used to resolve it. |
Returns
Type | Description |
---|---|
System. |
|
Exceptions
Type | Condition |
---|---|
Couchbase |
Thrown with Lite |
SetDocumentExpiration(String, Nullable<DateTimeOffset>)
Sets an expiration date on a document. After this time, the document will be purged from the collection.
Declaration
public bool SetDocumentExpiration(string docId, DateTimeOffset? expiration)
Parameters
Type | Name | Description |
---|---|---|
System. |
docId | The ID of the Document |
System. |
expiration | Nullable expiration timestamp as a
System. |
Returns
Type | Description |
---|---|
System. |
Whether successfully sets an expiration date on the document |
Exceptions
Type | Condition |
---|---|
Couchbase |
Throws NOT FOUND error if the document doesn't exist |
Couchbase |
Thrown with Lite |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System. |