@@ -64,6 +64,7 @@ abstract class _BaseAdapter<T extends DataModelMixin<T>> with _Lifecycle {
6464 /// Give access to the dependency injection system
6565 @nonVirtual
6666 Ref get ref => _ref! ;
67+ bool inIsolate = false ;
6768
6869 @visibleForTesting
6970 @protected
@@ -101,10 +102,12 @@ abstract class _BaseAdapter<T extends DataModelMixin<T>> with _Lifecycle {
101102
102103 @mustCallSuper
103104 @nonVirtual
104- Future <Adapter <T >> initialize ({required Ref ref}) async {
105+ Future <Adapter <T >> initialize (
106+ {required Ref ref, bool inIsolate = false }) async {
105107 if (isInitialized) return this as Adapter <T >;
106108
107109 _ref = ref;
110+ this .inIsolate = inIsolate;
108111
109112 // hook for clients
110113 await onInitialized ();
@@ -140,6 +143,15 @@ abstract class _BaseAdapter<T extends DataModelMixin<T>> with _Lifecycle {
140143 return deserializeFromResult (result);
141144 }
142145
146+ // TODO test
147+ /// Finds many models of type [T] by [ids] in local storage.
148+ List <T > findManyLocalByIds (Iterable <Object > ids) {
149+ final result = db.select (
150+ 'SELECT $internalType .key, data FROM $internalType JOIN _keys ON _keys.key = $internalType .key WHERE id IN (${ids .map ((_ ) => '?' ).join (', ' )})' ,
151+ ids.map ((id) => id.toString ()).toList ());
152+ return deserializeFromResult (result);
153+ }
154+
143155 @protected
144156 List <T > deserializeFromResult (ResultSet result) {
145157 return result.map ((r) {
@@ -220,7 +232,7 @@ abstract class _BaseAdapter<T extends DataModelMixin<T>> with _Lifecycle {
220232 // initialize and register
221233 for (final adapter in _internalAdaptersMap! .values) {
222234 adapter.dispose ();
223- await adapter.initialize (ref: _ref);
235+ await adapter.initialize (ref: _ref, inIsolate : true );
224236 }
225237
226238 final adapter = internalProvidersMap[_internalType]! ;
0 commit comments