DITStore

@interface DITStore : NSObject

The entrypoint for all actions that relate to data stored by DittoKit.

DITStore provides access to DITCollections, a write transaction API, and a query hash API.

  • Returns a DittoCollection with the provided name.

    Declaration

    Objective-C

    - (nonnull DITCollection *)objectForKeyedSubscript:
        (nonnull NSString *)collectionName;

    Parameters

    collectionName

    The name of the collection.

    Return Value

    A DITCollection.

  • Returns a DittoCollection with the provided name.

    Declaration

    Objective-C

    - (nonnull DITCollection *)collection:(nonnull NSString *)name;

    Parameters

    name

    The name of the collection.

    Return Value

    A DITCollection.

  • Returns a list of the names of collections in the store.

    Declaration

    Objective-C

    - (nonnull NSArray<NSString *> *)collectionNames;

    Return Value

    A list of collection names found in the store.

  • Returns a hash representing the current version of the given queries.

    When a document matching such queries gets mutated, the hash will change as well.

    Please note that the hash depends on how queries are constructed, so you should make sure to always compare hashes generated with the same set of queries.

    Declaration

    Objective-C

    - (NSUInteger)queriesHash:(nonnull NSArray<DITLiveQuery *> *)queries;

    Parameters

    queries

    A list of DITLiveQuery objects that you want to get the hash for.

    Return Value

    A hash representing the current version of the given queries.

  • Returns a sequence of English words representing the current version of the given queries.

    When a document matching such queries gets mutated, the words will change as well.

    Please note that the resulting sequence of words depends on how queries are constructed, so you should make sure to always compare hashes generated with the same set of queries.

    Declaration

    Objective-C

    - (nonnull NSString *)queriesHashMnemonic:
        (nonnull NSArray<DITLiveQuery *> *)queries;

    Parameters

    queries

    A list of DITLiveQuery objects that you want to get the mnemonic hash for.

    Return Value

    A string representing the current version of the given queries.

  • Allows you to group multiple operations together that affect multiple documents, potentially across multiple collections.

    Declaration

    Objective-C

    - (nonnull NSArray<DITWriteTransactionResult *> *)write:
        (nonnull void (^)(DITWriteTransaction *_Nonnull))block;

    Parameters

    block

    A block that provides access to a write transaction object that can be used to perform operations on the store.

    Return Value

    A list of DITWriteTransactionResults. There is a result for each operation performed as part of the write transaction.