16 NS_REQUIRES_PROPERTY_DEFINITIONS
34 + (instancetype) modelForNewDocumentInDatabase: (
CBLDatabase*)database;
48 @property (readonly)
bool isNew;
50 #pragma mark - SAVING: 54 - (BOOL) save: (NSError**)outError;
77 - (BOOL) deleteDocument: (NSError**)outError;
91 error: (NSError**)outError;
96 #pragma mark - PROPERTIES & ATTACHMENTS: 100 - (
nullable id) getValueOfProperty: (NSString*)property;
104 - (BOOL) setValue: (
nullable id)value
105 ofProperty: (NSString*)property;
121 fromClass: (
nullable Class)fromClass;
137 - (void) setAttachmentNamed: (NSString*)name
138 withContentType: (NSString*)mimeType
139 content: (NSData*)content;
150 - (void) setAttachmentNamed: (NSString*)name
151 withContentType: (NSString*)mimeType
152 contentURL: (NSURL*)fileURL;
156 - (void) removeAttachmentNamed: (NSString*)name;
159 #pragma mark - PROTECTED (FOR SUBCLASSES TO OVERRIDE) 177 - (
CBLDatabase*) databaseForModelProperty: (NSString*)propertyName;
185 - (void) willSave: (
nullable NSSet*)changedPropertyNames;
203 + (
nullable Class) itemClassForArrayProperty: (NSString*)property;
218 + (
nullable NSString*) inverseRelationForArrayProperty: (NSString*)property;
236 - (BOOL) saveAllModels: (NSError**)outError;
241 - (BOOL) autosaveAllModels: (NSError**)outError;
instancetype NS_UNAVAILABLE()
#define NS_ASSUME_NONNULL_BEGIN
Definition: CBLBase.h:20
void markNeedsSave()
Marks the model as having unsaved content, ensuring that it will get saved after a short interval (if...
A CouchbaseLite database.
Definition: CBLDatabase.h:38
void awakeFromInitializer()
#define nullable
Definition: CBLBase.h:22
bool isNew
Is this model new, never before saved?
Definition: CBLModel.h:48
void revertChanges()
Removes any changes made to properties and attachments since the last save.
A CouchbaseLite document (as opposed to any specific revision of it.)
Definition: CBLDocument.h:16
void didLoadFromDocument()
Called when the model's properties are reloaded from the document.
bool needsSave
Does this model have unsaved changes?
Definition: CBLModel.h:65
NSDictionary * propertiesToSaveForDeletion()
If you want properties to be saved in the document when it's deleted (in addition to the required "_d...
NSDictionary * propertiesToSave()
The document's current properties (including unsaved changes) in externalized JSON format...
#define NS_ASSUME_NONNULL_END
Definition: CBLBase.h:21
Generic model class for CouchbaseLite documents.
Definition: CBLModel.h:24
CBLDatabase * database
The database the item's document belongs to.
Definition: CBLModel.h:45
NSString * type
The type of document.
Definition: CBLModel.h:223
NSTimeInterval autosaveDelay
How long to wait after the first change before auto-saving, if autosaves is true. ...
Definition: CBLModel.h:62
A generic class with runtime support for dynamic properties.
Definition: CBLDynamicObject.h:15
CBLArrayOf(NSNumber *) *CBLGeoPointToCoordPair(CBLGeoPoint pt)
Converts a point to a JSON-compatible array of two coordinates.
void markExternallyChanged()
Resets the timeSinceExternallyChanged property to zero.
NSTimeInterval timeSinceExternallyChanged
The time interval since the document was last changed externally (e.g.
Definition: CBLModel.h:81
A binary attachment to a document revision.
Definition: CBLAttachment.h:18
bool autosaves
Should changes be saved back to the database automatically? Defaults to NO, requiring you to call -sa...
Definition: CBLModel.h:58
CBLDatabase methods for use with CBLModel.
Definition: CBLModel.h:230
CBLDocument * document
The document this item is associated with.
Definition: CBLModel.h:40