Couchbase Lite
Objective-C API for iOS and Mac OS
CBLDocument.h
Go to the documentation of this file.
1 //
2 // CBLDocument.h
3 // CouchbaseLite
4 //
5 // Created by Pasin Suriyentrakorn on 12/29/16.
6 // Copyright © 2016 Couchbase. All rights reserved.
7 //
8 
9 #import <Foundation/Foundation.h>
10 #import "CBLProperties.h"
11 @class CBLDatabase;
12 @protocol CBLConflictResolver;
13 
14 NS_ASSUME_NONNULL_BEGIN
15 
17 extern NSString* const kCBLDocumentChangeNotification;
18 
24 extern NSString* const kCBLDocumentSavedNotification;
25 
29 extern NSString* const kCBLDocumentIsExternalUserInfoKey;
30 
31 
37 
38 - (instancetype) init NS_UNAVAILABLE;
39 
41 @property (readonly, nonatomic) NSString* documentID;
42 
44 @property (readonly, nonatomic) CBLDatabase* database;
45 
47 @property (readonly, nonatomic) BOOL isDeleted;
48 
51 @property (readonly, nonatomic) BOOL exists;
52 
58 @property (readonly, nonatomic) uint64_t sequence;
59 
62 @property (nonatomic, nullable) id<CBLConflictResolver> conflictResolver;
63 
69 - (BOOL) save: (NSError**)error;
70 
77 - (BOOL) deleteDocument: (NSError**)error;
78 
82 - (BOOL) purge: (NSError**)error;
83 
85 - (void) revert;
86 
87 @end
88 
89 
91 
93 - (nullable id) objectForKeyedSubscript: (NSString*)key;
94 
96 - (void) setObject: (nullable id)value forKeyedSubscript: (NSString*)key;
97 
98 @end
99 
100 NS_ASSUME_NONNULL_END
101 
102 // TODO:
103 // 1. Modellable
A Couchbase Lite database.
Definition: CBLDatabase.h:77
uint64_t sequence
Sequence number of the document in the database.
Definition: CBLDocument.h:58
A Couchbase Lite document.
Definition: CBLDocument.h:36
BOOL isDeleted
Is the document deleted?
Definition: CBLDocument.h:47
void revert()
Reverts unsaved changes made to the document&#39;s properties.
Definition: CBLDocument.h:90
NSString *const kCBLDocumentIsExternalUserInfoKey
Key in the userInfo dictionary of a kCBLDocumentSavedNotification.
CBLDatabase * database
The document&#39;s owning database.
Definition: CBLDocument.h:44
NSString * documentID
The document&#39;s ID.
Definition: CBLDocument.h:41
instancetype NS_UNAVAILABLE()
BOOL exists
Checks whether the document exists in the database or not.
Definition: CBLDocument.h:51
NS_ASSUME_NONNULL_BEGIN NSString *const kCBLDocumentChangeNotification
Notification posted by a CBLDocument when a property is changed in memory.
Abstract interface for an application-defined object that can resolve a conflict between two revision...
Definition: CBLConflictResolver.h:18
Default implementation of CBLProperties protocol, which defines a JSON-compatible object...
Definition: CBLProperties.h:104
NSString *const kCBLDocumentSavedNotification
Notification posted by a CBLDocument when it is updated in the database.
id< CBLConflictResolver > conflictResolver
The conflict resolver, if any, specific to this document.
Definition: CBLDocument.h:62