Couchbase Lite
Objective-C API for iOS and Mac OS
Instance Methods | Properties | List of all members
CBLDocument Class Reference

A CouchbaseLite document (as opposed to any specific revision of it.) More...

#import <CBLDocument.h>

Inheritance diagram for CBLDocument:

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...
 
(CBLSavedRevision *) - revisionWithID:
 The revision with the specified ID. More...
 
(NSArray *) - getRevisionHistory:
 Returns the document's history as an array of CBLRevisions. More...
 
(NSArray *) - getConflictingRevisions:
 Returns all the current conflicting revisions of the document. More...
 
(NSArray *) - 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...
 
(id) - propertyForKey:
 Shorthand for [self.properties objectForKey: key]. More...
 
(id) - objectForKeyedSubscript:
 Same as -propertyForKey:. More...
 
(CBLSavedRevision *) - putProperties:error:
 Saves a new revision. More...
 
(CBLSavedRevision *) - update:error:
 Saves a new revision by letting the caller update the existing properties. More...
 

Properties

CBLDatabasedatabase
 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...
 
NSString * currentRevisionID
 The ID of the current revision (if known; else nil). More...
 
CBLSavedRevisioncurrentRevision
 The current/latest revision. More...
 
NSDictionary * properties
 The contents of the current revision of the document. More...
 
NSDictionary * userProperties
 The user-defined properties, without the ones reserved by CouchDB. More...
 
id< CBLDocumentModelmodelObject
 Optional reference to an application-defined model object representing this document. More...
 

Detailed Description

A CouchbaseLite document (as opposed to any specific revision of it.)

Method Documentation

- (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.

- (CBLSavedRevision*) revisionWithID: (NSString *)  revisionID

The revision with the specified ID.

- (NSArray*) getRevisionHistory: (NSError **)  outError

Returns the document's history as an array of CBLRevisions.

(See CBLRevision's method.)

- (NSArray*) 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.

- (NSArray*) 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.

- (id) propertyForKey: (NSString *)  key

Shorthand for [self.properties objectForKey: key].

- (id) objectForKeyedSubscript: (NSString *)  key

Same as -propertyForKey:.

Enables "[]" access in Xcode 4.4+

- (CBLSavedRevision*) putProperties: (NSDictionary *)  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.)

- (CBLSavedRevision*) update: (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!

Parameters
blockWill be called on each attempt to save. Should update the given revision's properties and then return YES, or just return NO to cancel.
outErrorWill 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.
Returns
The new saved revision, or nil on error or cancellation.

Property Documentation

- (CBLDatabase*) database
readatomicassign

The document's owning database.

- (NSString*) documentID
readatomicassign

The document's ID.

- (NSString*) abbreviatedID
readatomicassign

An abbreviated form of the the documentID that looks like "xxxx..xxxx".

Useful in logging.

- (BOOL) isDeleted
readatomicassign

Is this document deleted? (That is, does its current revision have the '_deleted' property?)

- (BOOL) isGone
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?)

- (NSString*) currentRevisionID
readatomiccopy

The ID of the current revision (if known; else nil).

- (CBLSavedRevision*) currentRevision
readatomicassign

The current/latest revision.

This object is cached.

- (NSDictionary*) properties
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.

- (NSDictionary*) userProperties
readatomiccopy

The user-defined properties, without the ones reserved by CouchDB.

This is based on -properties, with every key whose name starts with "_" removed.

- (id<CBLDocumentModel>) modelObject
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.


The documentation for this class was generated from the following file: