diff --git a/LeStorage/StoredCollection.swift b/LeStorage/StoredCollection.swift index 9577538..a67821a 100644 --- a/LeStorage/StoredCollection.swift +++ b/LeStorage/StoredCollection.swift @@ -178,7 +178,22 @@ public class StoredCollection: 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) 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) throws { defer { self._hasChanged = true