diff --git a/CHANGELOG.md b/CHANGELOG.md index 70622b2..88915c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.1 + +* Add `deleteEntity` in case the caller does not have access to the primary key used by the connector (e.g. if it's a combined one) + ## 1.1.0 * Adds reactivity diff --git a/lib/src/index_entity_store.dart b/lib/src/index_entity_store.dart index 001a87c..42f2625 100644 --- a/lib/src/index_entity_store.dart +++ b/lib/src/index_entity_store.dart @@ -163,6 +163,10 @@ class IndexedEntityStore { deleteMany({key}); } + void deleteEntity(T entity) { + delete(_connector.getPrimaryKey(entity)); + } + void deleteMany(Set keys) { for (final key in keys) { _database.execute( diff --git a/pubspec.yaml b/pubspec.yaml index 7059ef1..b7a448f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: indexed_entity_store description: A fast, simple, and synchronous entity store for Flutter applications. -version: 1.1.0 +version: 1.1.1 repository: https://github.com/LunaONE/indexed_entity_store environment: diff --git a/test/indexed_entity_store_test.dart b/test/indexed_entity_store_test.dart index 9053458..9d64c5d 100644 --- a/test/indexed_entity_store_test.dart +++ b/test/indexed_entity_store_test.dart @@ -190,9 +190,13 @@ void main() { expect(fooByQueryValueNotExists.value, isEmpty); // add another one only matching the _all_ query - fooStore.insert( - _FooEntity(id: 2, valueA: 'something_else', valueB: 2, valueC: true), + final entity2 = _FooEntity( + id: 2, + valueA: 'something_else', + valueB: 2, + valueC: true, ); + fooStore.insert(entity2); expect(allFoos.value, hasLength(2)); expect(fooById1.value, isA<_FooEntity>()); @@ -219,7 +223,7 @@ void main() { fooByQueryValueNotExists.dispose(); // No more subscriptions, so this has no effect - fooStore.delete(2); + fooStore.deleteEntity(entity2); expect(fooStore.subscriptionCount, 0); },