or method

RealtimeQueryBuilder<T> or(
  1. void build(
    1. RealtimeQueryOrGroupBuilder group
    )
)

Adds an $or block to the query with the specified group of clauses. Each clause in the group is defined using the same operators as the where method. For example:

queryBuilder.or((group) {
  group.where('status', isEqualTo: 'active');
  group.where('age', isGreaterThan: 30);
}).or((group) {
  group.where('role', isEqualTo: 'admin');
 group.where('lastLogin', isLowerThan: DateTime.now().subtract(Duration(days: 30)));
});

This will produce a query filter equivalent to:

{
  "$and": [
    {
      "$or": [
        {"status": "active"},
        {"age": {"$gt": 30}}
      ]
    },
    {
      "$or": [
        {"role": "admin"},
        {"lastLogin": {"$lt": "Time value representing 30 days ago"}}
      ]
    }
 ]
}

Implementation

RealtimeQueryBuilder<T> or(
  void Function(RealtimeQueryOrGroupBuilder group) build,
) {
  final group = RealtimeQueryOrGroupBuilder._();
  build(group);

  if (group._clauses.isEmpty) {
    return this;
  }

  return _copyWith(ast: _ast.addOr(group._clauses));
}