getInitialCollection method
Future<Map<String, DynamicMap> ?>
getInitialCollection(
- ModelAdapterCollectionQuery query, {
- String? prefix,
Load the document corresponding to query
from _registeredInitialValue
.
If data is found, it is returned in DynamicMap.
If no data is found or the path is invalid, Null is returned.
prefix
can be specified to prefix the path.
_registeredInitialValue
からquery
に対応するドキュメントを読み込みます。
データが見つかった場合はDynamicMapで返されます。
データが見つからなかったり、パスに不正があった場合はNullが返されます。
prefix
を指定するとパスにプレフィックスを付与可能です。
Implementation
Future<Map<String, DynamicMap>?> getInitialCollection(
ModelAdapterCollectionQuery query, {
String? prefix,
}) async {
_addCollectionListener(query, prefix: prefix);
await _initialize();
await onLoad?.call(this);
final trimPath = _path(query.query.path, prefix);
final res = <String, DynamicMap>{};
for (final entry in _registeredInitialValue.entries) {
final path = entry.key.trimQuery().trimString("/");
final parentPath = path.parentPath();
if (parentPath != trimPath) {
continue;
}
final id = path.last();
final value = entry.value;
res[id] = Map<String, dynamic>.from(value);
}
if (res.isEmpty) {
return null;
}
return res;
}