onlyTrashed method

Query<T> onlyTrashed()

Retrieves only soft-deleted models.

This method applies a condition to only select models where the soft-delete field is not null.

Example:

final deletedUsers = await context.query<User>()
  .onlyTrashed()
  .get();

Implementation

Query<T> onlyTrashed() {
  final field = _softDeleteField;
  if (field == null) {
    return this;
  }
  return withTrashed().whereNotNull(field.columnName);
}