snapshotCollections function

List<Map<String, dynamic>> snapshotCollections(
  1. Object? json
)

The collections of a schema snapshot (GET /api/v1/admin/migrations/snapshot): a [...] list, {collections: [...]}, or either inside the {data: ...} envelope.

Implementation

List<Map<String, dynamic>> snapshotCollections(Object? json) {
  if (json is List) {
    return [for (final c in json) (c as Map).cast<String, dynamic>()];
  }
  if (json is Map && json['collections'] is List) {
    return snapshotCollections(json['collections']);
  }
  if (json is Map && json.containsKey('data')) {
    return snapshotCollections(json['data']);
  }
  throw const FormatException('Unrecognized schema shape');
}