create method

Future<DbCreateResponse> create(
  1. dynamic data
)

创建文档

Implementation

Future<DbCreateResponse> create(dynamic data) async {
  data = Serializer.encode(data);

  Map<String, dynamic> params = {
    'data': data,
  };

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

  CloudBaseResponse res = await _docRequest('database.addDocument', params);
  if (res.code != null) {
    return DbCreateResponse(
      code: res.code,
      message: res.message,
      requestId: res.requestId,
    );
  }

  return DbCreateResponse(requestId: res.requestId, id: res.data['_id']);
}