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

An unsaved new revision. More...

#import <CBLRevision.h>

Inheritance diagram for CBLUnsavedRevision:
CBLRevision

Instance Methods

(void) - setObject:forKeyedSubscript:
 
(CBLSavedRevision *) - save:
 Saves the new revision to the database. More...
 
(CBLSavedRevision *) - saveAllowingConflict:
 A special variant of -save: that always adds the revision, even if its parent is not the current revision of the document. More...
 
(void) - setAttachmentNamed:withContentType:content:
 Creates, updates or deletes an attachment. More...
 
(void) - setAttachmentNamed:withContentType:contentURL:
 Creates, updates or deletes an attachment whose body comes from a file. More...
 
(void) - removeAttachmentNamed:
 Removes the attachment with the given name. More...
 
- Instance Methods inherited from CBLRevision
(NSArray *) - getRevisionHistory:
 Returns the ancestry of this revision as an array of CBLRevisions, in chronological order. More...
 
(id) - propertyForKey:
 Shorthand for [self.properties objectForKey: key]. More...
 
(id) - objectForKeyedSubscript:
 Same as -propertyForKey:. More...
 
(CBLAttachment *) - attachmentNamed:
 Looks up the attachment with the given name (without fetching its contents yet). More...
 

Properties

BOOL isDeletion
 
NSMutableDictionary * properties
 
NSDictionary * userProperties
 
- Properties inherited from CBLRevision
CBLDocumentdocument
 The document this is a revision of. More...
 
CBLDatabasedatabase
 The database this revision's document belongs to. More...
 
BOOL isDeletion
 Does this revision mark the deletion of its document? (In other words, does it have a "_deleted" property?) More...
 
BOOL isGone
 Does this revision mark the deletion or removal (from available channels) of its document ? (In other words, does it have a "_deleted_ or "_removed" property?) More...
 
NSString * revisionID
 The ID of this revision. More...
 
CBLSavedRevisionparentRevision
 The revision this one is a child of. More...
 
NSString * parentRevisionID
 The ID of the parentRevision. More...
 
NSDictionary * properties
 The revision's contents as parsed from JSON. More...
 
NSDictionary * userProperties
 The user-defined properties, without the ones reserved by CouchbaseLite. More...
 
NSArray * attachmentNames
 The names of all attachments (an array of strings). More...
 
NSArray * attachments
 All attachments, as CBLAttachment objects. More...
 

Detailed Description

An unsaved new revision.

Most of its API is inherited from CBLRevisionBase.

Method Documentation

- (void) setObject: (id)  object
forKeyedSubscript: (NSString *)  key 
- (CBLSavedRevision*) save: (NSError **)  outError

Saves the new revision to the database.

This will fail with a 412 error if its parent (the revision it was created from) is not the current revision of the document. Afterwards you should use the returned CBLSavedRevision instead of this object.

Returns
A new CBLSavedRevision representing the saved form of the revision.
- (CBLSavedRevision*) saveAllowingConflict: (NSError **)  outError

A special variant of -save: that always adds the revision, even if its parent is not the current revision of the document.

This can be used to resolve conflicts, or to create them. If you're not certain that's what you want to do, you should use the regular -save: method instead.

- (void) setAttachmentNamed: (NSString *)  name
withContentType: (NSString *)  mimeType
content: (NSData *)  content 

Creates, updates or deletes an attachment.

The attachment data will be written to the database when the revision is saved.

Parameters
nameThe attachment name. By convention, this looks like a filename.
mimeTypeThe MIME type of the content.
contentThe body of the attachment.
- (void) setAttachmentNamed: (NSString *)  name
withContentType: (NSString *)  mimeType
contentURL: (NSURL *)  fileURL 

Creates, updates or deletes an attachment whose body comes from a file.

(The method takes a URL, but it must be a "file:" URL. Remote resources are not supported.) The file need only be readable. It won't be moved or altered in any way. The attachment data will be copied from the file into the database when the revision is saved. The file needs to be preserved until then, but afterwards it can safely be deleted.

Parameters
nameThe attachment name. By convention, this looks like a filename.
mimeTypeThe MIME type of the content.
fileURLThe URL of a local file whose contents should be copied into the attachment.
- (void) removeAttachmentNamed: (NSString *)  name

Removes the attachment with the given name.

When this revision is saved, it won't include the attachment. However, the attachment will still be present in the parent revision, until the database is next compacted.

Property Documentation

- (BOOL) isDeletion
readwriteatomicassign
- (NSMutableDictionary*) properties
readwriteatomiccopy
- (NSDictionary*) userProperties
readwriteatomiccopy

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