persistDocument method

Future<void> persistDocument(
  1. TDocument document
)

Persists the document in the store.

Implementation

Future<void> persistDocument(TDocument document) async {
  final oldRaw = await store.toMap();
  final newRaw = document.toJson();
  final changes = _findActualDocumentChanges(oldRaw, newRaw);

  for (var entry in changes.entryToUpdate.entries) {
    await store.persist(entry.key, entry.value);
  }

  for (var key in changes.keyToDelete) {
    await store.delete(key);
  }
}