delete method

Future<void> delete(
  1. String collection, {
  2. required JsonMap filter,
  3. bool optimistic = false,
})

Deletes documents from collection matching filter.

If optimistic is true, the cache removes the matching documents immediately while waiting for the server confirmation.

Implementation

Future<void> delete(
  String collection, {
  required JsonMap filter,
  bool optimistic = false,
}) async {
  final filterPayload = _deepCopyMap(filter);

  if (optimistic) {
    _queryManager.optimisticDelete(
      collection: collection,
      filter: filterPayload,
    );
  }
  await _webSocketService.send({
    'type': 'realtime:delete',
    'collection': collection,
    'filter': filterPayload,
  });
}