Adds a delete sequence method

multistore
Laurent 2 years ago
parent 2323c46273
commit b0c03a7651
  1. 17
      LeStorage/StoredCollection.swift

@ -178,7 +178,22 @@ public class StoredCollection<T: Storable>: RandomAccessCollection, SomeCollecti
}
/// Inserts the whole sequence into the items array, no updates
/// Deletes all items of the sequence by id
public func delete(contentOfs sequence: any Sequence<T>) throws {
defer {
self._hasChanged = true
}
for instance in sequence {
try instance.deleteDependencies()
self.items.removeAll { $0.id == instance.id }
self._index?.removeValue(forKey: instance.stringId)
try self._sendDeletionIfNecessary(instance)
}
}
/// Inserts or updates all items in the sequence
public func addOrUpdate(contentOfs sequence: any Sequence<T>) throws {
defer {
self._hasChanged = true

Loading…
Cancel
Save