JSONStoreCollection Class Reference
Inherits from | NSObject |
Declared in | JSONStoreCollection.h |
Contains JSONStore methods that operate on a single collection.
Tasks
collectionName property
searchFields property
additionalSearchFields property
reopened property
_dropFirst property
– initWithName:
– setSearchField:withType:
– setAdditionalSearchField:withType:
– removeCollectionWithError:
– clearCollectionWithError:
– addData:andMarkDirty:withOptions:error:
– replaceDocuments:andMarkDirty:error:
– findWithQueryParts:andOptions:error:
– findAllWithOptions:error:
– findWithIds:andOptions:error:
– countAllDocumentsAndReturnError:
– countWithQueryParts:error:
– countAllDirtyDocumentsWithError:
– markDocumentsClean:error:
– allDirtyAndReturnError:
– isDirtyWithDocumentId:error:
– changeData:withReplaceCriteria:addNew:markDirty:error:
– removeWithIds:andMarkDirty:error:
Properties
_dropFirst
Private. Remove the collection (drop table [collection]) before initializing.
@property (nonatomic) BOOL _dropFirst
Availability
IBM Worklight V6.2.0 @private
Declared In
JSONStoreCollection.h
additionalSearchFields
Additional Search fields that are tied to the collection.
@property (nonatomic, strong) NSMutableDictionary *additionalSearchFields
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
collectionName
Name of the collection.
@property (nonatomic, strong) NSString *collectionName
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
reopened
Boolean that shows if the collection was reopened (true) or newly created (false).
@property (nonatomic, getter=wasReopened) BOOL reopened
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
searchFields
Search fields that are tied to a collection.
@property (nonatomic, strong) NSMutableDictionary *searchFields
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
Instance Methods
addData:andMarkDirty:withOptions:error:
Stores data as documents in the collection.
- (NSNumber *)addData:(NSArray *)data andMarkDirty:(BOOL)markDirty withOptions:(JSONStoreAddOptions *)options error:(NSError **)error
Parameters
- data
-
NSArray of JSON data represented as NSDictionaries
- markDirty
-
Determines if the documents that are added should be marked dirty (true) or not (false)
- options
-
Options for handling things like additional search fields
- error
-
Error
Return Value
Number data added, nil if there is a failure
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
allDirtyAndReturnError:
Get all documents that are marked dirty in the collection.
- (NSArray *)allDirtyAndReturnError:(NSError **)error
Parameters
- error
-
Error
Return Value
NSArray of all dirty documents in the collection, nil if there is a failure
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
changeData:withReplaceCriteria:addNew:markDirty:error:
Uses a replacement criteria to locate documents for a targeted replacement, if no existing document is found it checks the addNew flag to determine if a new document should be added.
- (NSNumber *)changeData:(NSArray *)data withReplaceCriteria:(NSArray *)replaceCriteriaSearchFields addNew:(BOOL)addNew markDirty:(BOOL)markDirty error:(NSError **)error
Parameters
- data
-
NSArray of JSON objects as NSDictionary
- addNew
-
Determines if new JSON objects are added to the store if they are not already inside (true) or not (false)
- markDirty
-
Determines if the operation marks changes as dirty (true) or not (false)
- error
-
Error
Return Value
Number of documents changed, nil if there is a failure
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
clearCollectionWithError:
Permanently deletes all the documents stored in a collection while preserving the accessor for the collection.
- (BOOL)clearCollectionWithError:(NSError **)error
Parameters
- error
-
Error
Return Value
Boolean that indicates the operation failed (false) or succeeded (true)
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
countAllDirtyDocumentsWithError:
Returns the total number of dirty documents in the collection.
- (NSNumber *)countAllDirtyDocumentsWithError:(NSError **)error
Parameters
- error
-
Error
Return Value
Number of documents that are dirty in the collection, nil if there is a failure
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
countAllDocumentsAndReturnError:
Returns the total number of documents that exist in the collection.
- (NSNumber *)countAllDocumentsAndReturnError:(NSError **)error
Parameters
- error
-
Error
Return Value
Number of documents in the collection, nil if there is a failure
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
countWithQueryParts:error:
Returns the total number of documents that match the query parts.
- (NSNumber *)countWithQueryParts:(NSArray *)queryParts error:(NSError **)error
Parameters
- queryParts
-
Array of JSONStoreQueryPart objects
- error
-
Error
Return Value
Number of documents that matched the query parts, nil if there is a failure
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
findAllWithOptions:error:
Returns all documents in the collection.
- (NSArray *)findAllWithOptions:(JSONStoreQueryOptions *)options error:(NSError **)error
Parameters
- options
-
Options such as filter, sort, limit, and offset
- error
-
Error
Return Value
All documents in the collection, nil if there is a failure
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
findWithIds:andOptions:error:
Returns all documents that match the _id values passed.
- (NSArray *)findWithIds:(NSArray *)ids andOptions:(JSONStoreQueryOptions *)options error:(NSError **)error
Parameters
- ids
-
array of _id field values that is represented as an integers
- options
-
Options such as filter, sort, limit, and offset
- error
-
Error
Return Value
Documents found with matching _id fields, nil if there is a failure
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
findWithQueryParts:andOptions:error:
Locates documents inside a collection by using one or more query parts.
- (NSArray *)findWithQueryParts:(NSArray *)queryParts andOptions:(JSONStoreQueryOptions *)options error:(NSError **)error
Parameters
- queryParts
-
Array of JSONStoreQueryPart objects
- options
-
Options such as filter, sort, limit, and offset
- error
-
Error
Return Value
All documents in the collection that matched the query parts, nil if there is a failure
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
initWithName:
Creates a new JSONStoreCollection instance for the collection with the given name.
- (JSONStoreCollection *)initWithName:(NSString *)collectionName
Parameters
- collectionName
-
the name of the collection
Return Value
new instance
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
isDirtyWithDocumentId:error:
Returns whether the document represented by the given _id value is dirty or not.
- (BOOL)isDirtyWithDocumentId:(int)_id error:(NSError **)error
Parameters
- _id
-
The _id field value of the document
- error
-
Error
Return Value
True if the document is dirty, false otherwise
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
markDocumentsClean:error:
Takes input from allDirtyAndReturnError: (which returns documents with an _operation key value pair) and marks documents as clean.
- (NSNumber *)markDocumentsClean:(NSArray *)documents error:(NSError **)error
Parameters
- documents
-
NSArray of documents that are represented as NSDictionaries
- error
-
Error
Return Value
Number of documents marked clean, nil if there is a failure
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
removeCollectionWithError:
Permanently deletes all the documents stored in a collection and removes the accessor for that collection.
- (BOOL)removeCollectionWithError:(NSError **)error
Parameters
- error
-
Error
Return Value
Boolean that indicates the operation failed (false) or succeeded (true)
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
removeWithIds:andMarkDirty:error:
Removes documents from the collection by using one or more _id values. Removed documents are not returned by the different find operations and they do not affect count operations.
- (NSNumber *)removeWithIds:(NSArray *)ids andMarkDirty:(BOOL)markDirty error:(NSError **)error
Parameters
- ids
-
NSArray of _id values represented as integers
- markDirty
-
Determines if the documents that are removed are marked as dirty (true) or not (false)
- error
-
Error
Return Value
Number documents removed, nil if there is a failure
Availability
IBM Worklight V6.2.0 @private
Declared In
JSONStoreCollection.h
replaceDocuments:andMarkDirty:error:
This method is used to modify documents inside a collection by replacing existing documents with given documents. The field used to perform the replacement is the document’s unique identifier (_id).
- (NSNumber *)replaceDocuments:(NSArray *)documents andMarkDirty:(BOOL)markDirty error:(NSError **)error
Parameters
- documents
-
Array of documents represented as NSDictionaries with the following key value pairs: _id (integer) and json (NSDictionary).
- markDirty
-
Determines if the documents that are replaced should be marked dirty (true) or not (false)
- error
-
Error
Return Value
Number documents replaced, nil if there is a failure
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
setAdditionalSearchField:withType:
Sets the given additional search field for the collection. Must be called before opening the collection. Cannot be changed after the collection is opened.
- (void)setAdditionalSearchField:(NSString *)additionalSearchField withType:(JSONStoreSearchFieldType)type
Parameters
- additionalSearchField
-
the name of the additional search field
- type
-
the type of the additional search field
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
setSearchField:withType:
Sets the given search field for the collection. Must be called before opening the collection. Cannot be changed after the collection is opened.
- (void)setSearchField:(NSString *)searchField withType:(JSONStoreSearchFieldType)type
Parameters
- searchField
-
the name of the search field
- type
-
the type of the search field
Availability
IBM Worklight V6.2.0
Declared In
JSONStoreCollection.h
© Copyright IBM Corp. 2017