jsonToCollection method
Future<void>
jsonToCollection({
- required String path,
- required JsonObject json,
- required OnParsedCallback onParsed,
- String? changeRootName,
Implementation
Future<void> jsonToCollection({
required String path,
required JsonObject json,
required OnParsedCallback onParsed,
String? changeRootName,
}) async {
final collectionName = changeRootName ?? (json[metaName] as String?) ?? '';
if (collectionName.isEmpty) {
throw FormatException('Wrong `$metaName` value=`$collectionName` '
'in json=`$json`');
}
final collectionPath = di<PathUtils>().join(
path,
collectionName,
);
final innerDocuments = _jsonCollectionToDocuments(json);
for (final innerDocument in innerDocuments) {
await jsonToDocument(
path: collectionPath,
json: innerDocument,
onParsed: onParsed,
);
}
}