whereHas<TChild> method

S whereHas<TChild>(
  1. MssqlRelation<TRow, TChild> relation(
    1. TFields fields
    )
)

Keeps parents that have at least one matching related row.

Correlated EXISTS, not a join: a customer with ten orders is still one customer. The handle's where/withTrashed/then filters are the same snapshot include would load.

Implementation

S whereHas<TChild>(
  MssqlRelation<TRow, TChild> Function(TFields fields) relation,
) {
  final rel = relation(fields);
  return where((_) => MssqlExistsSubquery(_existsQuery(rel), negated: false));
}