File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ //
2+ // LogicalQueryOperator.swift
3+ //
4+ //
5+ // Created by Alsey Coleman Miller on 8/21/23.
6+ //
7+
8+ import Foundation
9+ import Predicate
10+
11+ /// Logical Query Operators
12+ ///
13+ /// Logical operators return data based on expressions that evaluate to true or false.
14+ ///
15+ /// [Documentation](https://www.mongodb.com/docs/v7.0/reference/operator/query-comparison/)
16+ public enum LogicalQueryOperator : String , Codable , CaseIterable {
17+
18+ /// Joins query clauses with a logical AND returns all documents that match the conditions of both clauses.
19+ case and = " $and "
20+
21+ /// Joins query clauses with a logical OR returns all documents that match the conditions of either clause.
22+ case or = " $or "
23+
24+ /// Inverts the effect of a query expression and returns documents that do not match the query expression.
25+ case not = " $not "
26+
27+ /// Joins query clauses with a logical NOR returns all documents that fail to match both clauses.
28+ case nor = " $nor "
29+ }
30+
31+ // MARK: - Predicate
32+
33+ public extension LogicalQueryOperator {
34+
35+ init ( predicate: Compound . Logical Type) {
36+ switch predicate {
37+ case . and:
38+ self = . and
39+ case . or:
40+ self = . or
41+ case . not:
42+ self = . not
43+ }
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments