loadDocument method
Pass query
and load the document corresponding to query
.
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.
query
を渡してquery
に対応するドキュメントを読み込みます。
データが見つかった場合はDynamicMap
で返されます。
データが見つからなかったり、パスに不正があった場合はNullが返されます。
prefix
を指定するとパスにプレフィックスを付与可能です。
Implementation
Future<DynamicMap?> loadDocument(
ModelAdapterDocumentQuery query, {
String? prefix,
}) async {
_addDocumentListener(query, prefix: prefix);
await _initialize();
await onLoad?.call(this);
final trimPath = _path(query.query.path, prefix);
final paths = trimPath.split("/");
if (paths.isEmpty) {
return null;
}
final value = data._readFromPath(paths, 0);
if (value is! Map) {
return null;
}
return Map<String, dynamic>.from(value);
}