updateDocument method

Future<Response> updateDocument({
  1. required String collectionId,
  2. required String documentId,
  3. required Map data,
  4. List? read,
  5. List? write,
})

Update Document

Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.

Implementation

Future<req.Response> updateDocument(
    {required String collectionId,
    required String documentId,
    required Map data,
    List? read,
    List? write}) {
  final String path =
      '/database/collections/{collectionId}/documents/{documentId}'
          .replaceAll(RegExp('{collectionId}'), collectionId)
          .replaceAll(RegExp('{documentId}'), documentId);

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

  final Map<String, String> headers = {
    'content-type': 'application/json',
  };

  return client.call(HttpMethod.patch,
      path: path, params: params, headers: headers);
}