orWhereHas method

Query orWhereHas(
  1. dynamic tableName,
  2. Query function(
    1. Query
    )?
)

Implementation

Query orWhereHas(tableName, Query Function(Query)? function) {
  if (!_lastQuery.contains('WHERE')) {
    _lastQuery += ' WHERE ';
  } else {
    _lastQuery += ' OR ';
  }
  String has = ' EXISTS ( ';
  if (function != null) {
    Query q = function(Query(table: tableName));
    has += 'SELECT ${q._select == '' ? '*' : q._select} FROM $tableName ' + q._joinQuery + ' ' + q._lastQuery;
  }
  has += ' ) ';
  _lastQuery += has + ' ';
  return this;
}