The document type, an interface; defaults to CBLDictionary.
ReadonlyconfigThe configuration with which the Collection was created.
ReadonlydatabaseThe owning Database.
Protected ReadonlydbReadonlynameThe Collection's name.
Adds a listener function that will be called after any document(s) change. If documents are changed while in a transaction, the listener is not called until the transaction successfully commits.
Note: Purged and expired documents do not trigger notifications.
The function to be called after documents change.
A ListenerToken whose ListenerToken.remove method you can call to remove the listener.
Adds a listener function that will be called after a specific document changes.
Note: If the document is changed while in a transaction, the listener is not called until the transaction successfully commits.
Note: Purged and expired documents do not trigger notifications.
The ID of the document to monitor.
The function to be called after the document changes.
A ListenerToken whose ListenerToken.remove method you can call to remove the listener.
By default, returns the number of documents in the collection.
If what is "deleted", it returns the number of deleted docs ("tombstones".)
If what is "includeDeleted", it returns the total number of live and deleted docs.
Creates a new document instance tied to this collection. The document will not be persisted to the database until you save it.
Deletes a document from this collection.
Deletion leaves behind an invisible "tombstone" revision, a placeholder that's used by the Replicator to sync the deletion back to a server. If you don't want the overhead, and this deletion does not need to be synced, consider using purge instead.
Conflicts can occur when deleting, just as on a regular save. A ConflictHandler allows you to handle them.
Performance note: If you are deleting multiple documents, use updateMultiple instead; it's much faster than saving one at a time.
The document.
OptionalonConflict: ConflictHandler<D>Optional conflict handler callback.
true if saved, false if the ConflictHandler decided to 'revert'.
Returns the DocIDs of all deleted documents.
Returns the DocIDs of all (undeleted) documents.
OptionalonConflict: ConflictHandler<D>Invokes the callback with each (undeleted) Document of the Collection, ordered by docID. The callback should return true to continue, or false to stop the iteration.
True if the iteration completed, false if it was stopped.
Loads an existing document, or returns undefined if it doesn't exist.
Gets a document's expiration date.
The expiration date, or undefined if none, or if the document doesn't exist.
Deletes all traces of a document, without leaving a "tombstone" revision behind. However, this means purges are not visible to the replicator, which has two side effects:
The document or DocID.
Purges multiple documents at once.
Saves a document to this collection.
If the document in the database has been changed since this instance was read -- by your app or by a replicator pulling revisions from a server -- a conflict occurs. By default, a ConflictError will be thrown. If you pass a ConflictHandler callback, it will be invoked during the save and can decide how to resolve the conflict.
Performance note: If you are saving multiple documents to a collection, use updateMultiple instead; it's much faster than saving one at a time.
OptionalonConflict: ConflictHandler<D>Optional conflict handler callback.
true if saved, false if the ConflictHandler decided to 'revert'.
Sets or clears an expiration date for a document.
The document or DocID
Can be an absolute Date,
or a number interpreted as milliseconds into the future,
or undefined to disable expiration.
Saves and/or deletes multiple documents at once in a single database transaction. This is much faster than saving each individually.
The args object has the following properties, all optional:
save: Array of CBLDocuments to savedelete: Array of CBLDocuments to deleteonConflict: Conflict handlerbestEffort: If true, the transaction will commit even if some documents had errors.
An error will still be thrown, though.MultipleConflictsError if any documents failed to update.
Its errors property tells which documents failed and why.
Represents a single collection (namespace) of documents in a Database.