-
-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from vapor/raw
raw + sql cleanup
- Loading branch information
Showing
58 changed files
with
1,523 additions
and
1,262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/// Defines a `Filter` that can be | ||
/// added on fetch, delete, and update | ||
/// operations to limit the set of | ||
/// data affected. | ||
public struct Filter { | ||
public enum Relation { | ||
case and, or | ||
} | ||
|
||
public enum Method { | ||
case compare(String, Comparison, Node) | ||
case subset(String, Scope, [Node]) | ||
case group(Relation, [RawOr<Filter>]) | ||
} | ||
|
||
public init(_ entity: Entity.Type, _ method: Method) { | ||
self.entity = entity | ||
self.method = method | ||
} | ||
|
||
public var entity: Entity.Type | ||
public var method: Method | ||
} | ||
|
||
extension Filter: CustomStringConvertible { | ||
public var description: String { | ||
switch method { | ||
case .compare(let field, let comparison, let value): | ||
return "(\(entity)) \(field) \(comparison) \(value)" | ||
case .subset(let field, let scope, let values): | ||
let valueDescriptions = values.map { $0.string ?? "" } | ||
return "(\(entity)) \(field) \(scope) \(valueDescriptions)" | ||
case .group(let relation, let filters): | ||
return filters.map { $0.description }.joined(separator: "\(relation)") | ||
} | ||
} | ||
} |
Oops, something went wrong.