InMemoryDataStore
An in-memory implementation of DataStore.
This implementation is mainly intended for testing and example applications.
<T>
the data type data that this implementation can handle.
<E>
the type of Edits that this implementation can handle.
-
Default init.
Declaration
Swift
public init()
-
Saves a client document.
Declaration
Swift
public func saveClientDocument(document: ClientDocument<T>)
Parameters
clientDocument
the ClientDocument to save.
-
Retrieves the ClientDocument matching the passed-in document documentId.
Declaration
Swift
public func getClientDocument(documentId: String, clientId: String) -> ClientDocument<T>?
Parameters
documentId
the document id of the shadow document.
clientId
the client for which to retrieve the shadow document.
Return Value
ClientDocument the client document matching the documentId.
-
Saves a shadow document.
Declaration
Swift
public func saveShadowDocument(shadow: ShadowDocument<T>)
Parameters
shadowDocument
the ShadowDocument to save.
-
Retrieves the ShadowDocument matching the passed-in document documentId.
Declaration
Swift
public func getShadowDocument(documentId: String, clientId: String) -> ShadowDocument<T>?
Parameters
documentId
the document id of the shadow document.
clientId
the client for which to retrieve the shadow document.
Return Value
ShadowDocument the shadow document matching the documentId.
-
Saves a backup shadow document.
Declaration
Swift
public func saveBackupShadowDocument(backup: BackupShadowDocument<T>)
Parameters
backupShadow
the BackupShadowDocument to save.
-
Retrieves the BackupShadowDocument matching the passed-in document documentId.
Declaration
Swift
public func getBackupShadowDocument(documentId: String, clientId: String) -> BackupShadowDocument<T>?
Parameters
documentId
the document identifier of the backup shadow document.
clientId
the client identifier for which to fetch the document.
Return Value
BackupShadowDocument the backup shadow document matching the documentId.
-
Saves an Edit to the data store.
Declaration
Swift
public func saveEdits(edit: E)
Parameters
edit
the edit to be saved.
documentId
the document identifier for the edit.
clientId
the client identifier for the edit.
-
Retreives the array of Edits for the specified document documentId.
Declaration
Swift
public func getEdits(documentId: String, clientId: String) -> [E]?
Parameters
documentId
the document identifier of the edit.
clientId
the client identifier for which to fetch the document.
Return Value
[D] the edits for the document.
-
Removes the edit from the store.
Declaration
Swift
public func removeEdit(edit: E)
Parameters
edit
the edit to be removed.
documentId
the document identifier for the edit.
clientId
the client identifier for the edit.
-
Removes all edits for the specific client and document pair.
Declaration
Swift
public func removeEdits(documentId: String, clientId: String)
Parameters
documentId
the document identifier of the edit.
clientId
the client identifier.