get method

Implementation

Future<DbQueryResponse> get() async {
  if (_id == null) {
    return DbQueryResponse(
      code: CloudBaseExceptionCode.INVALID_PARAM,
      message: 'docId不能为空',
    );
  }

  Map<String, dynamic> query = {'_id': this._id};
  Map<String, dynamic> params = {
    'query': query,
    'multi': false,
    'projection': _projection,
  };

  CloudBaseResponse res = await _docRequest('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'],
  );
}