createDocument method

Future<Response> createDocument({
  1. required String collectionId,
  2. required Map data,
  3. List? read,
  4. List? write,
  5. String? parentDocument,
  6. String? parentProperty,
  7. String? parentPropertyType,
})

Create Document

Create a new Document. Before using this route, you should create a new collection resource using either a server integration API or directly from your database console.

Implementation

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

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

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

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