DataStoreBaseBehavior

public protocol DataStoreBaseBehavior
  • save(_:where:) Asynchronous

    Saves the model to storage. If sync is enabled, also initiates a sync of the mutation to the remote API

    Declaration

    Swift

    @discardableResult
    func save<M: Model>(_ model: M,
                        where condition: QueryPredicate?) async throws -> M
  • query(_:byId:) Asynchronous

    Declaration

    Swift

    func query<M: Model>(_ modelType: M.Type,
                         byId id: String) async throws -> M?
  • query(_:byIdentifier:) Asynchronous

    Declaration

    Swift

    func query<M: Model>(_ modelType: M.Type,
                         byIdentifier id: String) async throws -> M?
        where M: ModelIdentifiable, M.IdentifierFormat == ModelIdentifierFormat.Default
  • query(_:byIdentifier:) Asynchronous

    Declaration

    Swift

    func query<M: Model>(_ modelType: M.Type,
                         byIdentifier id: ModelIdentifier<M, M.IdentifierFormat>) async throws -> M?
        where M: ModelIdentifiable
  • Declaration

    Swift

    func query<M: Model>(_ modelType: M.Type,
                         where predicate: QueryPredicate?,
                         sort sortInput: QuerySortInput?,
                         paginate paginationInput: QueryPaginationInput?) async throws -> [M]
  • delete(_:where:) Asynchronous

    Declaration

    Swift

    func delete<M: Model>(_ model: M,
                          where predicate: QueryPredicate?) async throws
  • Declaration

    Swift

    func delete<M: Model>(_ modelType: M.Type,
                          withId id: String,
                          where predicate: QueryPredicate?) async throws
  • Declaration

    Swift

    func delete<M: Model>(_ modelType: M.Type,
                          withIdentifier id: String,
                          where predicate: QueryPredicate?) async throws where M: ModelIdentifiable,
                                                                               M.IdentifierFormat == ModelIdentifierFormat.Default
  • Declaration

    Swift

    func delete<M: Model>(_ modelType: M.Type,
                          withIdentifier id: ModelIdentifier<M, M.IdentifierFormat>,
                          where predicate: QueryPredicate?) async throws where M: ModelIdentifiable
  • delete(_:where:) Asynchronous

    Declaration

    Swift

    func delete<M: Model>(_ modelType: M.Type,
                           where predicate: QueryPredicate) async throws
  • start() Asynchronous

    Synchronization starts automatically whenever you run any DataStore operation (query(), save(), delete()) however, you can explicitly begin the process with DatasStore.start()

    Declaration

    Swift

    func start() async throws

    Parameters

    completion

    callback to be invoked on success or failure

  • stop() Asynchronous

    To stop the DataStore sync process, you can use DataStore.stop(). This ensures the real time subscription connection is closed when your app is no longer interested in updates, such as when you application is closed. This can also be used to modify DataStore sync expressions at runtime by calling stop(), then start() to force your sync expressions to be re-evaluated.

    Declaration

    Swift

    func stop() async throws

    Parameters

    completion

    callback to be invoked on success or failure

  • clear() Asynchronous

    To clear local data from DataStore, use the clear method.

    Declaration

    Swift

    func clear() async throws

    Parameters

    completion

    callback to be invoked on success or failure