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

Detailed Description

A Couchbase Lite document.

A document has key/value properties like an NSDictionary; their API is defined by the protocol CBLProperties. To learn how to work with properties, see that protocol's documentation.

Inheritance diagram for CBLDocument:
CBLProperties <CBLProperties>

Instance Methods

(instancetype) - NS_UNAVAILABLE
 
(BOOL) - save:
 Saves property changes back to the database. More...
 
(BOOL) - deleteDocument:
 Deletes this document. More...
 
(BOOL) - purge:
 Purges this document from the database. More...
 
(void) - revert
 Reverts unsaved changes made to the document's properties. More...
 
(nullable id) - objectForKeyedSubscript:
 Same as objectForKey: More...
 
(void) - setObject:forKeyedSubscript:
 Same as setObject:forKey: More...
 
- Instance Methods inherited from <CBLProperties>
(nullable id) - objectForKey:
 Gets an property's value as an object. More...
 
(BOOL) - booleanForKey:
 Gets a property's value as a boolean. More...
 
(NSInteger) - integerForKey:
 Gets a property's value as an integer. More...
 
(float) - floatForKey:
 Gets a property's value as a float. More...
 
(double) - doubleForKey:
 Gets a property's value as a double. More...
 
(nullable NSString *) - stringForKey:
 Gets a property's value as a string. More...
 
(nullable NSDate *) - dateForKey:
 Gets a property's value as an NSDate. More...
 
(void) - setObject:forKey:
 Sets a property value by key. More...
 
(void) - setBoolean:forKey:
 Sets a boolean value by key. More...
 
(void) - setInteger:forKey:
 Sets an integer value by key. More...
 
(void) - setFloat:forKey:
 Sets a float value by key. More...
 
(void) - setDouble:forKey:
 Sets a double value by key. More...
 
(void) - removeObjectForKey:
 Removes a property by key. More...
 
(BOOL) - containsObjectForKey:
 Tests whether a property exists or not. More...
 

Properties

NSString * documentID
 The document's ID. More...
 
CBLDatabasedatabase
 The document's owning database. More...
 
BOOL isDeleted
 Is the document deleted? More...
 
BOOL exists
 Checks whether the document exists in the database or not. More...
 
uint64_t sequence
 Sequence number of the document in the database. More...
 
id< CBLConflictResolverconflictResolver
 The conflict resolver, if any, specific to this document. More...
 
- Properties inherited from <CBLProperties>
NSDictionary * properties
 All of the properties contained in this object. More...
 

Method Documentation

- (instancetype) NS_UNAVAILABLE

Implements CBLProperties.

- (BOOL) save: (NSError **)  error

Saves property changes back to the database.

If the document in the database has been updated since it was read by this CBLDocument, a conflict occurs, which will be resolved by invoking the conflict handler. This can happen if multiple application threads are writing to the database, or a pull replication is copying changes from a server.

- (BOOL) deleteDocument: (NSError **)  error

Deletes this document.

All properties are removed, and subsequent calls to -documentWithID: will return nil. Deletion adds a special "tombstone" revision to the database, as bookkeeping so that the change can be replicated to other databases. Thus, it does not free up all of the disk space occupied by the document. To delete a document entirely (but without the ability to replicate this), use -purge:.

- (BOOL) purge: (NSError **)  error

Purges this document from the database.

This is more drastic than deletion: it removes all traces of the document. The purge will NOT be replicated to other databases.

- (void) revert

Reverts unsaved changes made to the document's properties.

- (nullable id) objectForKeyedSubscript: (NSString *)  key

Same as objectForKey:

Reimplemented from <CBLProperties>.

Provided by category CBLDocument(Subscripts).

- (void) setObject: (nullable id)  value
forKeyedSubscript: (NSString *)  key 

Same as setObject:forKey:

Reimplemented from <CBLProperties>.

Provided by category CBLDocument(Subscripts).

Property Documentation

- (NSString*) documentID
readnonatomicassign

The document's ID.

- (CBLDatabase*) database
readnonatomicassign

The document's owning database.

- (BOOL) isDeleted
readnonatomicassign

Is the document deleted?

- (BOOL) exists
readnonatomicassign

Checks whether the document exists in the database or not.

If not, saving it will create it.

- (uint64_t) sequence
readnonatomicassign

Sequence number of the document in the database.

This indicates how recently the document has been changed: every time any document is updated, the database assigns it the next sequential sequence number. Thus, if a document's sequence property changes that means it's been changed (on-disk); and if one document's sequence is greater than another's, that means it was changed more recently.

- (id<CBLConflictResolver>) conflictResolver
readwritenonatomicassign

The conflict resolver, if any, specific to this document.

If nil, the database's conflict resolver will be used.


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