Couchbase Lite
Objective-C API for iOS and Mac OS
CBLTimeSeries.h
Go to the documentation of this file.
1 //
2 // CBLTimeSeries.h
3 // CouchbaseLite
4 //
5 // Created by Jens Alfke on 10/26/15.
6 // Copyright © 2015 Couchbase, Inc. All rights reserved.
7 //
8 
9 #import "CBLBase.h"
11 
12 
14 
17 @interface CBLTimeSeries : NSObject
18 
24 - (nullable instancetype) initWithDatabase: (CBLDatabase*)db
25  docType: (NSString*)docType
26  error: (NSError**)error;
27 
29 @property (readonly) NSString* docType;
30 
33 @property (copy) NSString* docIDPrefix;
34 
37 @property (readonly, nullable) NSError* lastError;
38 
40 - (void) addEvent: (CBLJSONDict*)event;
41 
44 - (void) addEvent: (CBLJSONDict*)event atTime: (CFAbsoluteTime)time;
45 
49 - (void) flushAsync: (void(^)(BOOL))onFlushed;
50 
54 - (BOOL) flush;
55 
57 - (void) stop;
58 
59 
61 
69 - (CBLReplication*) createPushReplication: (NSURL*)remoteURL
70  purgeWhenPushed: (BOOL)purgeWhenPushed;
71 
72 
74 
82 - (NSEnumerator<CBLJSONDict*>*) eventsFromDate: (nullable NSDate*)startDate
83  toDate: (nullable NSDate*)endDate
84  error: (NSError**)outError;
85 
90 typedef void (^CBLTimeSeriesEnumerationBlock)(CBLJSONDict* event, CFAbsoluteTime time, BOOL *stop);
91 
96 + (BOOL) enumerateEventsInDocument: (CBLJSONDict*)doc
97  usingBlock: (CBLTimeSeriesEnumerationBlock)block;
98 
99 @end
100 
void stop()
Stops the CBLTimeSeries, immediately flushing all pending events.
#define NS_ASSUME_NONNULL_BEGIN
Definition: CBLBase.h:20
A CouchbaseLite database.
Definition: CBLDatabase.h:38
Efficiently stores small time-stamped JSON values into a database, and can replicate them to a server...
Definition: CBLTimeSeries.h:17
#define nullable
Definition: CBLBase.h:22
NSString * docType
The "type" property that will be added to documents.
Definition: CBLTimeSeries.h:29
void(^ CBLTimeSeriesEnumerationBlock)(CBLJSONDict *event, CFAbsoluteTime time, BOOL *stop)
Callback for single-document enumeration.
Definition: CBLTimeSeries.h:90
#define NS_ASSUME_NONNULL_END
Definition: CBLBase.h:21
NSString * docIDPrefix
A prefix for the IDs of documents created by this object.
Definition: CBLTimeSeries.h:33
A &#39;push&#39; or &#39;pull&#39; replication between a local and a remote database.
Definition: CBLReplication.h:35
NSError * lastError
The latest error encountered.
Definition: CBLTimeSeries.h:37
BOOL flush()
Writes all pending events to documents before returning.