![]() |
Couchbase Lite
Objective-C API for iOS and Mac OS
|
A CouchbaseLite document (as opposed to any specific revision of it.)
Instance Methods | |
| (BOOL) | - deleteDocument: |
| Deletes this document by adding a deletion revision. More... | |
| (BOOL) | - purgeDocument: |
| Purges this document from the database; this is more than deletion, it forgets entirely about it. More... | |
| (nullable CBLSavedRevision *) | - revisionWithID: |
| The revision with the specified ID. More... | |
| (nullable CBLArrayOf(CBLSavedRevision *) | - getRevisionHistory: |
| Returns the document's history as an array of CBLRevisions. More... | |
| (nullable CBLArrayOf(CBLSavedRevision *) | - getConflictingRevisions: |
| Returns all the current conflicting revisions of the document. More... | |
| (nullable CBLArrayOf(CBLSavedRevision *) | - getLeafRevisions: |
| Returns all the leaf revisions in the document's revision tree, including deleted revisions (i.e. More... | |
| (CBLUnsavedRevision *) | - newRevision |
| Creates an unsaved new revision whose parent is the currentRevision, or which will be the first revision if the document doesn't exist yet. More... | |
| (nullable id) | - propertyForKey: |
| Shorthand for [self.properties objectForKey: key]. More... | |
| (nullable id) | - objectForKeyedSubscript: |
| Same as -propertyForKey:. More... | |
| (nullable CBLSavedRevision *) | - putProperties:error: |
| Saves a new revision. More... | |
| (nullable CBLSavedRevision *) | - update:error: |
| Saves a new revision by letting the caller update the existing properties. More... | |
| (BOOL) | - putExistingRevisionWithProperties:attachments:revisionHistory:fromURL:error: |
| Adds an existing revision copied from another database. More... | |
| (instancetype) | - NS_UNAVAILABLE |
Properties | |
| CBLDatabase * | database |
| The document's owning database. More... | |
| NSString * | documentID |
| The document's ID. More... | |
| NSString * | abbreviatedID |
| An abbreviated form of the the documentID that looks like "xxxx..xxxx". More... | |
| BOOL | isDeleted |
| Is this document deleted? (That is, does its current revision have the '_deleted' property?) More... | |
| BOOL | isGone |
| Has this document either been deleted or removed from available Sync Gateway channels? (That is, does its current revision have a '_deleted' or '_removed' property?) More... | |
| NSDate * | expirationDate |
| A date/time after which this document will be automatically purged. More... | |
| NSString * | currentRevisionID |
| The ID of the current revision (if known; else nil). More... | |
| CBLSavedRevision * | currentRevision |
| The current/latest revision. More... | |
| CBLJSONDict * | properties |
| The contents of the current revision of the document. More... | |
| CBLJSONDict * | userProperties |
| The user-defined properties, without the ones reserved by CouchDB. More... | |
| id< CBLDocumentModel > | modelObject |
| Optional reference to an application-defined model object representing this document. More... | |
| - (BOOL) deleteDocument: | (NSError **) | outError |
Deletes this document by adding a deletion revision.
This will be replicated to other databases.
| - (BOOL) purgeDocument: | (NSError **) | outError |
Purges this document from the database; this is more than deletion, it forgets entirely about it.
The purge will NOT be replicated to other databases.
| - (nullable CBLSavedRevision*) revisionWithID: | (NSString *) | revisionID |
The revision with the specified ID.
| - (nullable CBLArrayOf(CBLSavedRevision*) getRevisionHistory: | (NSError **) | outError |
Returns the document's history as an array of CBLRevisions.
(See CBLRevision's method.)
| - (nullable CBLArrayOf(CBLSavedRevision*) getConflictingRevisions: | (NSError **) | outError |
Returns all the current conflicting revisions of the document.
If the document is not in conflict, only the single current revision will be returned.
| - (nullable CBLArrayOf(CBLSavedRevision*) getLeafRevisions: | (NSError **) | outError |
Returns all the leaf revisions in the document's revision tree, including deleted revisions (i.e.
previously-resolved conflicts.)
| - (CBLUnsavedRevision*) newRevision |
Creates an unsaved new revision whose parent is the currentRevision, or which will be the first revision if the document doesn't exist yet.
You can modify this revision's properties and attachments, then save it. No change is made to the database until/unless you save the new revision.
| - (nullable id) propertyForKey: | (NSString *) | key |
Shorthand for [self.properties objectForKey: key].
| - (nullable id) objectForKeyedSubscript: | (NSString *) | key |
Same as -propertyForKey:.
Enables "[]" access in Xcode 4.4+
| - (nullable CBLSavedRevision*) putProperties: | (CBLJSONDict *) | properties | |
| error: | (NSError **) | outError | |
Saves a new revision.
The properties dictionary must have a "_rev" property whose ID matches the current revision's (as it will if it's a modified copy of this document's .properties property.)
| - (nullable CBLSavedRevision*) update: | (BOOL(^)(CBLUnsavedRevision *)) | block | |
| error: | (NSError **) | outError | |
Saves a new revision by letting the caller update the existing properties.
This method handles conflicts by retrying (calling the block again). The block body should modify the properties of the new revision and return YES to save or NO to cancel. Be careful: the block can be called multiple times if there is a conflict!
| block | Will be called on each attempt to save. Should update the given revision's properties and then return YES, or just return NO to cancel. |
| outError | Will point to the error, if the method returns nil. (If the callback block cancels by returning nil, the error will be nil.) If this parameter is NULL, no error will be stored. |
| - (BOOL) putExistingRevisionWithProperties: | (CBLJSONDict *) | properties | |
| attachments: | (nullable NSDictionary *) | attachments | |
| revisionHistory: | (CBLArrayOf(NSString *) *) | revIDs | |
| fromURL: | (nullable NSURL *) | sourceURL | |
| error: | (NSError **) | outError | |
Adds an existing revision copied from another database.
Unlike a normal insertion, this does not assign a new revision ID; instead the revision's ID must be given. The revision's history (ancestry) must be given, which can put it anywhere in the revision tree. It's not an error if the revision already exists locally; it will just be ignored.
This is not an operation that clients normally perform; it's used by the replicator. You might want to use it if you're pre-loading a database with canned content, or if you're implementing some new kind of replicator that transfers revisions from another database.
| properties | The properties of the revision (_id and _rev will be ignored, but _deleted and _attachments are recognized.) |
| attachments | A dictionary providing attachment bodies. The keys are the attachment names (matching the keys in the properties' _attachments dictionary) and the values are the attachment bodies as NSData or NSURL. |
| revIDs | The revision history in the form of an array of revision-ID strings, in reverse chronological order. The first item must be the new revision's ID. Following items are its parent's ID, etc. |
| sourceURL | The URL of the database this revision came from, if any. (This value shows up in the CBLDatabaseChange triggered by this insertion, and can help clients decide whether the change is local or not.) |
| outError | Error information will be stored here if the insertion fails. |
| - (instancetype) NS_UNAVAILABLE |
|
readatomicassign |
The document's owning database.
|
readatomicassign |
The document's ID.
|
readatomicassign |
An abbreviated form of the the documentID that looks like "xxxx..xxxx".
Useful in logging.
|
readatomicassign |
Is this document deleted? (That is, does its current revision have the '_deleted' property?)
|
readatomicassign |
Has this document either been deleted or removed from available Sync Gateway channels? (That is, does its current revision have a '_deleted' or '_removed' property?)
|
readwriteatomicstrong |
A date/time after which this document will be automatically purged.
|
readatomiccopy |
The ID of the current revision (if known; else nil).
|
readatomicassign |
The current/latest revision.
This object is cached.
|
readatomiccopy |
The contents of the current revision of the document.
This is shorthand for self.currentRevision.properties. Any keys in the dictionary that begin with "_", such as "_id" and "_rev", contain CouchbaseLite metadata.
|
readatomiccopy |
The user-defined properties, without the ones reserved by CouchDB.
This is based on -properties, with every key whose name starts with "_" removed.
|
readwriteatomicweak |
Optional reference to an application-defined model object representing this document.
Usually this is a CBLModel, but you can implement your own model classes if you want. Note that this is a weak reference.