public interface Store
| Modifier and Type | Method and Description |
|---|---|
RevisionInternal |
add(java.lang.String docID,
java.lang.String prevRevID,
java.util.Map<java.lang.String,java.lang.Object> properties,
boolean deleting,
boolean allowConflict,
StorageValidation validationBlock,
Status outStatus)
Creates a new revision of a document.
|
RevisionList |
changesSince(long lastSequence,
ChangesOptions options,
ReplicationFilter filter,
java.util.Map<java.lang.String,java.lang.Object> filterParams)
Returns all database changes with sequences greater than `lastSequence`.
|
void |
close()
Closes storage before it's deallocated.
|
void |
compact()
Explicitly compacts document storage.
|
boolean |
databaseExists(java.lang.String directory)
Preflight to see if a database file exists in this directory.
|
long |
expirationOfDocument(java.lang.String docID)
Returns a document's expiration date as a Unix timestamp, or 0 for no expiration.
|
java.util.Set<BlobKey> |
findAllAttachmentKeys()
Returns the keys (unique IDs) of all attachments referred to by existing un-compacted
Each revision key is an NSData object containing a CBLBlobKey (raw SHA-1 getDigest) derived from
the "digest" property of the attachment's metadata.
|
java.lang.String |
findCommonAncestorOf(RevisionInternal rev,
java.util.List<java.lang.String> revIDs)
Returns the most recent member of revIDs that appears in rev's ancestry.
|
int |
findMissingRevisions(RevisionList touchRevs)
Looks for each given revision in the local database, and removes each one found
from the list.
|
void |
forceInsert(RevisionInternal inRev,
java.util.List<java.lang.String> history,
StorageValidation validationBlock,
java.net.URL source)
Inserts an already-existing revision (with its revID), plus its ancestry, into a document.
|
java.util.Map<java.lang.String,java.lang.Object> |
getAllDocs(QueryOptions options)
Iterates over all documents in the database, according to the given query options.
|
RevisionList |
getAllRevisions(java.lang.String docID,
boolean onlyCurrent)
Returns all the known revisions (or all current/conflicting revisions) of a document.
|
java.util.List<java.lang.String> |
getAllViewNames()
Returns the names of all existing views in the database.
|
boolean |
getAutoCompact() |
StoreDelegate |
getDelegate() |
RevisionInternal |
getDocument(java.lang.String docID,
java.lang.String revID,
boolean withBody,
Status outStatus)
Retrieves a document revision by ID.
|
int |
getDocumentCount()
The number of (undeleted) documents in the database.
|
java.lang.String |
getInfo(java.lang.String key)
Returns the value assigned to the given key by -setInfo:forKey:.
|
long |
getLastSequence()
The last sequence number allocated to a revision.
|
RevisionInternal |
getLocalDocument(java.lang.String docID,
java.lang.String revID)
Returns the contents of a local document.
|
int |
getMaxRevTreeDepth() |
RevisionInternal |
getParentRevision(RevisionInternal rev)
Retrieves the parent revision of a revision, or returns nil if there is no parent.
|
java.util.List<java.lang.String> |
getPossibleAncestorRevisionIDs(RevisionInternal rev,
int limit,
java.util.concurrent.atomic.AtomicBoolean outHaveBodies,
boolean withBodiesOnly)
Returns IDs of local revisions of the same document, that have a lower generation number.
|
java.util.List<RevisionInternal> |
getRevisionHistory(RevisionInternal rev)
Returns the given revision's list of direct ancestors (as CBL_Revision objects) in _reverse_
chronological order, starting with the revision itself.
|
ViewStore |
getViewStorage(java.lang.String name,
boolean create)
Instantiates storage for a view.
|
boolean |
inTransaction()
Is a transaction active?
|
RevisionInternal |
loadRevisionBody(RevisionInternal rev)
Loads the body of a revision.
|
long |
nextDocumentExpiry()
Returns the next time at which a document will expire.
|
void |
open()
Opens storage.
|
int |
purgeExpiredDocuments()
Triggers purging of documents whose expiration time has passed.
|
java.util.Map<java.lang.String,java.lang.Object> |
purgeRevisions(java.util.Map<java.lang.String,java.util.List<java.lang.String>> docsToRevs)
Purges specific revisions, which deletes them completely from the local database
_without_ adding a "tombstone" revision.
|
RevisionInternal |
putLocalRevision(RevisionInternal revision,
java.lang.String prevRevID,
boolean obeyMVCC)
Creates / updates / deletes a local document.
|
boolean |
runInTransaction(TransactionalTask task)
Executes the block within a database transaction.
|
void |
setAutoCompact(boolean value)
Whether the database storage should automatically (periodically) be compacted.
|
void |
setDelegate(StoreDelegate delegate)
The delegate object, which in practice is the CBLDatabase.
|
boolean |
setExpirationOfDocument(long timestamp,
java.lang.String docID)
Sets a document's expiration to a Unix timestamp, or 0 for no expiration.
|
long |
setInfo(java.lang.String key,
java.lang.String info)
Stores an arbitrary string under an arbitrary key, persistently.
|
void |
setMaxRevTreeDepth(int maxRevTreeDepth)
The maximum depth a document's revision tree should grow to; beyond that,
it should be pruned.
|
boolean databaseExists(java.lang.String directory)
void open() throws CouchbaseLiteException
CouchbaseLiteExceptionvoid close()
void setDelegate(StoreDelegate delegate)
StoreDelegate getDelegate()
void setMaxRevTreeDepth(int maxRevTreeDepth)
int getMaxRevTreeDepth()
void setAutoCompact(boolean value)
boolean getAutoCompact()
long setInfo(java.lang.String key,
java.lang.String info)
java.lang.String getInfo(java.lang.String key)
int getDocumentCount()
long getLastSequence()
boolean inTransaction()
void compact()
throws CouchbaseLiteException
CouchbaseLiteExceptionboolean runInTransaction(TransactionalTask task)
RevisionInternal getDocument(java.lang.String docID, java.lang.String revID, boolean withBody, Status outStatus)
docID - The document IDrevID - The revision ID; may be nil, meaning "the current revision".withBody - If false, revision's body won't be loadedoutStatus - RevisionInternal loadRevisionBody(RevisionInternal rev) throws CouchbaseLiteException
CouchbaseLiteExceptionRevisionInternal getParentRevision(RevisionInternal rev)
java.util.List<RevisionInternal> getRevisionHistory(RevisionInternal rev)
RevisionList getAllRevisions(java.lang.String docID, boolean onlyCurrent)
docID - The document IDonlyCurrent - If true, only leaf revisions (whether or not deleted) should be returned.java.util.List<java.lang.String> getPossibleAncestorRevisionIDs(RevisionInternal rev, int limit, java.util.concurrent.atomic.AtomicBoolean outHaveBodies, boolean withBodiesOnly)
rev - The revision to look for ancestors of. Only its docID and revID are used.limit - The maximum number of results to return, or if 0, unlimited.outHaveBodies - On return, if not NULL, then *outHaveBodies will be YES if all the
revisions returned have their JSON bodies available, otherwise NO.withBodiesOnly - Specifies whether or not to search for non-empty and non-removed revisions.java.lang.String findCommonAncestorOf(RevisionInternal rev, java.util.List<java.lang.String> revIDs)
int findMissingRevisions(RevisionList touchRevs)
java.util.Set<BlobKey> findAllAttachmentKeys() throws CouchbaseLiteException
CouchbaseLiteExceptionjava.util.Map<java.lang.String,java.lang.Object> getAllDocs(QueryOptions options) throws CouchbaseLiteException
CouchbaseLiteExceptionRevisionList changesSince(long lastSequence, ChangesOptions options, ReplicationFilter filter, java.util.Map<java.lang.String,java.lang.Object> filterParams)
lastSequence - The sequence number to start _after_options - Options for ordering, document content, etc.filter - If non-nil, will be called on every revision,
and those for which it returns NO will be skipped.RevisionInternal add(java.lang.String docID, java.lang.String prevRevID, java.util.Map<java.lang.String,java.lang.Object> properties, boolean deleting, boolean allowConflict, StorageValidation validationBlock, Status outStatus) throws CouchbaseLiteException
docID - The document ID, or nil if an ID should be generated at random.prevRevID - The parent revision ID, or nil if creating a new document.properties - The new revision's properties. (Metadata other than "_attachments" ignored.)deleting - YES if this revision is a deletion.allowConflict - YES if this operation is allowed to create a conflict; otherwise a 409,
status will be returned if the parent revision is not a leaf.validationBlock - If non-nil, this block will be called before the revision is added.
It's given the parent revision, with its properties if available, and can reject
the operation by returning an error status.outStatus - On return a status will be stored here. Note that on success, the
status should be 201 for a created revision but 200 for a deletion.CouchbaseLiteExceptionvoid forceInsert(RevisionInternal inRev, java.util.List<java.lang.String> history, StorageValidation validationBlock, java.net.URL source) throws CouchbaseLiteException
inRev - The revision to insert. Its revID will be non-nil.history - The revIDs of the revision and its ancestors, in reverse chronological order.
The first item will be equal to inRev.revID.validationBlock - If non-nil, this block will be called before the revision is added.
It's given the parent revision, with its properties if available,
and can reject the operation by returning an error status.source - The URL of the remote database this was pulled from, or nil if it's local.
(This will be used to create the CBLDatabaseChange object sent to the delegate.)CouchbaseLiteExceptionjava.util.Map<java.lang.String,java.lang.Object> purgeRevisions(java.util.Map<java.lang.String,java.util.List<java.lang.String>> docsToRevs)
docsToRevs - A dictionary mapping document IDs to arrays of revision IDs.
The magic revision ID "*" means "all revisions", indicating that the
document should be removed entirely from the database.CouchbaseLiteExceptionlong expirationOfDocument(java.lang.String docID)
boolean setExpirationOfDocument(long timestamp,
java.lang.String docID)
long nextDocumentExpiry()
int purgeExpiredDocuments()
ViewStore getViewStorage(java.lang.String name, boolean create) throws CouchbaseLiteException
name - The name of the viewcreate - If YES, the view should be created; otherwise it must already existCouchbaseLiteExceptionjava.util.List<java.lang.String> getAllViewNames()
RevisionInternal getLocalDocument(java.lang.String docID, java.lang.String revID)
docID - The document ID, which will begin with "_local/"revID - revID The revision ID, or nil to return the current revision.RevisionInternal putLocalRevision(RevisionInternal revision, java.lang.String prevRevID, boolean obeyMVCC) throws CouchbaseLiteException
revision - The new revision to save. Its docID must be set but the revID is ignored.
If its .deleted property is YES, it's a deletion.prevRevID - The revision ID to replaceobeyMVCC - If YES, the prevRevID must match the document's current revID (or nil if the
document doesn't exist) or a 409 error is returned. If NO, the prevRevID is
ignored and the operation always succeeds.CouchbaseLiteException