get method

Implementation

Future<DbQueryResponse> get() async {
  Map<String, dynamic> params = {};

  if (this._fieldFilters != null) {
    params['query'] = this._fieldFilters;
  }

  if (this._fieldOrders!.length > 0) {
    params['order'] = List.from(this._fieldOrders!);
  }

  if (this._queryOptions!.limit != null) {
    params['limit'] = (this._queryOptions!.limit ?? 0) < 1000
        ? this._queryOptions!.limit
        : 1000;
  } else {
    this._queryOptions!.limit = 100;
  }

  if (this._queryOptions!.offset != null) {
    params['offset'] = this._queryOptions!.offset;
  }

  if (this._queryOptions!.projection != null) {
    params['projection'] = this._queryOptions!.projection;
  }

  CloudBaseResponse res = await _queryRequest(
    'database.queryDocument',
    params,
  );
  if (res.code != null) {
    return DbQueryResponse(
      code: res.code,
      message: res.message,
      requestId: res.requestId,
    );
  }

  return DbQueryResponse(
    requestId: res.requestId,
    data: Serializer.decode(res.data['list']),
    limit: res.data['limit'],
    offset: res.data['offset'],
  );
}