delete method

Future<APIResponse<Map<String, dynamic>>> delete([
  1. DeleteOptions? options
])

Deletes the document referred to by this DBObject and identified by the id. For a top level model object this method deletes the object from the database and for sub-model objects either unsets its value or removes it from its parent's object list. If the id of the db object is not defined, it returns an error.

If the client library key is set to enforce session, an active user session is required (e.g., user needs to be logged in) to call this method.

options Delete operation options. By default removes deleted object from Redis cache (if cached already) and no top level object return.

Returns null if the deleted object is a top-level object. If the deleted object is a sub-model object and if returnTop is set to true in DeleteOptions, it returns the updated top-level object.

Implementation

Future<APIResponse<Map<String, dynamic>>> delete([DeleteOptions? options]) =>
    _fetcher
        .post<Map<String, dynamic>>('/_api/rest/v1/db/object/delete', body: {
      'options': DEFAULT_DELETE_OPTIONS.merge(options).toJson(),
      'model': _modelName,
      'id': _id,
    });