Query.fromMap constructor

Query.fromMap(
  1. Map<String, dynamic> map
)

Query from socket data scheme

Implementation

Query.fromMap(Map<String, dynamic> map)
    : assert(map['query_type'] != null, "query_type must not be null"),
      assert(map["query_type"].runtimeType == int,
          "query_type must be an integer"),
      queryType = QueryType.values[map["query_type"]],
      token = AccessToken.fromToken(map['token']),
      allowAll = false,
      operationType =
          operationTypeFromQueryType(QueryType.values[map["query_type"]]) {
  collection = map['collection'];
  if (collection == null) {
    throw Exception('Collcetion Must be null');
  }

  // if (map['token'] == null) {
  //   throw Exception('Token must not be null');
  // }

  data = map['document'] ?? null;
  filters = map['filters'] ?? <String, dynamic>{};
  equals = map['equals'] ?? <String, dynamic>{};
  notEquals = map['not_equals'] ?? <String, dynamic>{};
  sorts = sortingCast(map['sorts']);
  update = map['update'] ?? <String, dynamic>{};
  limit = map['limit'] ?? 1000;
  offset = map['offset'] ?? 0;
  fileds = (map["fields"] as Map<String, dynamic>? ?? <String, dynamic>{})
      .cast<String, bool>();
}