fromJson<T> static method

QueryResult<T> fromJson<T>(
  1. Map<String, dynamic> json,
  2. T mapper(
    1. Map<String, dynamic>
    )
)

Creates from JSON with a mapper function

Implementation

static QueryResult<T> fromJson<T>(
  Map<String, dynamic> json,
  T Function(Map<String, dynamic>) mapper,
) {
  final docs = json['documents'] ?? json['data'] ?? json['results'] ?? <dynamic>[];
  return QueryResult<T>(
    data: (docs as List).map((e) => mapper(e as Map<String, dynamic>)).toList(),
    total: json['total'] as int?,
    limit: json['limit'] as int?,
    skip: json['skip'] as int?,
    hasMore: json['hasMore'] as bool? ?? false,
  );
}