Couchbase Lite
Objective-C API for iOS and Mac OS
CBLRevision.h
Go to the documentation of this file.
1 //
2 // CBLRevision.h
3 // CouchbaseLite
4 //
5 // Created by Jens Alfke on 6/17/12.
6 // Copyright (c) 2012-2013 Couchbase, Inc. All rights reserved.
7 //
8 
9 #import "CBLBase.h"
11 
13 
17 @interface CBLRevision : NSObject
18 
20 @property (readonly, weak) CBLDocument* document;
21 
23 @property (readonly) CBLDatabase* database;
24 
27 @property (readonly) BOOL isDeletion;
28 
31 @property (readonly) BOOL isGone;
32 
34 @property (readonly, nullable) NSString* revisionID;
35 
37 @property (readonly, nullable) CBLSavedRevision* parentRevision;
38 
40 @property (readonly, nullable) NSString* parentRevisionID;
41 
44 - (nullable CBLArrayOf(CBLRevision*)*) getRevisionHistory: (NSError**)outError;
45 
50 @property (readonly, nullable) CBLJSONDict* properties;
51 
54 @property (readonly, copy, nullable) CBLJSONDict* userProperties;
55 
57 - (nullable id) propertyForKey: (NSString*)key;
58 
60 - (nullable id) objectForKeyedSubscript: (NSString*)key;
61 
62 #pragma mark ATTACHMENTS
63 
65 @property (readonly, nullable) CBLArrayOf(NSString*)* attachmentNames;
66 
68 - (nullable CBLAttachment*) attachmentNamed: (NSString*)name;
69 
71 @property (readonly, nullable) CBLArrayOf(CBLAttachment*)* attachments;
72 
73 - (instancetype) init NS_UNAVAILABLE;
74 
75 @end
76 
77 
78 
81 
84 @property (readonly) BOOL propertiesAvailable;
85 
88 - (CBLUnsavedRevision*) createRevision;
89 
92 - (nullable CBLSavedRevision*) createRevisionWithProperties: (nullable CBLJSONDict*)properties
93  error: (NSError**)outError;
94 
96 - (nullable CBLSavedRevision*) deleteDocument: (NSError**)outError;
97 
98 @end
99 
100 
101 
104 
105 // These properties are overridden to be settable:
106 @property (readwrite) BOOL isDeletion;
107 @property (readwrite, copy, nullable) NSMutableDictionary* properties;
108 @property (readwrite, copy, nullable) CBLJSONDict* userProperties;
109 - (void) setObject: (nullable id)object forKeyedSubscript: (NSString*)key;
110 
115 - (nullable CBLSavedRevision*) save: (NSError**)outError;
116 
121 - (nullable CBLSavedRevision*) saveAllowingConflict: (NSError**)outError;
122 
128 - (void) setAttachmentNamed: (NSString*)name
129  withContentType: (nullable NSString*)mimeType
130  content: (nullable NSData*)content;
131 
140 - (void) setAttachmentNamed: (NSString*)name
141  withContentType: (nullable NSString*)mimeType
142  contentURL: (nullable NSURL*)fileURL;
143 
147 - (void) removeAttachmentNamed: (NSString*)name;
148 
149 @end
150 
151 
NSString * parentRevisionID
The ID of the parentRevision.
Definition: CBLRevision.h:40
NSString * revisionID
The ID of this revision.
Definition: CBLRevision.h:34
#define NS_ASSUME_NONNULL_BEGIN
Definition: CBLBase.h:20
A revision of a CBLDocument.
Definition: CBLRevision.h:17
CBLDocument * document
The document this is a revision of.
Definition: CBLRevision.h:20
BOOL isGone
Does this revision mark the deletion or removal (from available channels) of its document ...
Definition: CBLRevision.h:31
A CouchbaseLite database.
Definition: CBLDatabase.h:38
BOOL isDeletion
Does this revision mark the deletion of its document? (In other words, does it have a "_deleted" prop...
Definition: CBLRevision.h:27
#define nullable
Definition: CBLBase.h:22
A CouchbaseLite document (as opposed to any specific revision of it.)
Definition: CBLDocument.h:16
CBLJSONDict * userProperties
The user-defined properties, without the ones reserved by CouchbaseLite.
Definition: CBLRevision.h:54
An unsaved new revision.
Definition: CBLRevision.h:103
#define NS_ASSUME_NONNULL_END
Definition: CBLBase.h:21
CBLJSONDict * properties
The revision's contents as parsed from JSON.
Definition: CBLRevision.h:50
instancetype NS_UNAVAILABLE()
CBLArrayOf(NSString *) *attachmentNames
The names of all attachments (an array of strings).
An existing revision of a CBLDocument.
Definition: CBLRevision.h:80
CBLDatabase * database
The database this revision's document belongs to.
Definition: CBLRevision.h:23
A binary attachment to a document revision.
Definition: CBLAttachment.h:18
CBLSavedRevision * parentRevision
The revision this one is a child of.
Definition: CBLRevision.h:37