We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
BSONDocument.init(predicate:)
1 parent ad8b287 commit 1deaf94Copy full SHA for 1deaf94
1 file changed
Sources/MongoDBModel/Predicate.swift
@@ -46,15 +46,17 @@ public extension BSONDocument {
46
47
public extension BSONDocument {
48
49
- init?(predicate: Comparison) {
+ init?(predicate: FetchRequest.Predicate.Comparison) {
50
// { <field>: { $eq: <value> } }
51
+ guard case let .keyPath(keyPath) = predicate.left,
52
+ let comparisonOperator = ComparisonQueryOperator(predicate: predicate.type),
53
+ case let .value(value) = predicate.right,
54
+ predicate.options.isEmpty,
55
+ predicate.modifier == nil,
56
+ let valueBSON = try? BSON(attributeValue: value) else {
57
return nil
58
}
-}
-
-public extension BSON {
- init?(predicate: Expression) {
- return nil
59
+ self = [
60
+ keyPath.rawValue: .document([comparisonOperator.rawValue: valueBSON])]
61
62
0 commit comments