extract method

Map<String, dynamic> extract([
  1. String path = ''
])

Returns a map of the subset of documents in the store under the given path. Data for the given path can exist in two different places:

  1. It necessarily exists in all of the value stores resolved under the given path.
  2. It could exist in any of the parent value stores of the given path, such as in the example of the "users" path containing data for path users__1, users__1__friends__1, etc.

Implementation

Map<String, dynamic> extract([String path = '']) {
  _assertHydrated();

  Map<String, dynamic> data = {};

  final parentStores = _storeResolver.extractParentPath(path).values;
  final childStores = _storeResolver.extractValues(path);

  for (final store in parentStores) {
    data.addAll(store.extract(path));
  }
  for (final store in childStores) {
    data.addAll(store.extract(path));
  }

  return data;
}