File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed
main/com/mongodb/client/model
functional/com/mongodb/client/model
unit/com/mongodb/client/model Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,21 @@ public final class Filters {
53
53
private Filters () {
54
54
}
55
55
56
+ /**
57
+ * Creates a filter that matches all documents where the value of _id field equalss the specified value. Note that this does
58
+ * actually generate a $eq operator, as the query language doesn't require it.
59
+ *
60
+ * @param value the value
61
+ * @param <TItem> the value type
62
+ * @return the filter
63
+ * @mongodb.driver.manual reference/operator/query/eq $eq
64
+ *
65
+ * @since 3.4
66
+ */
67
+ public static <TItem > Bson eq (final TItem value ) {
68
+ return eq ("_id" , value );
69
+ }
70
+
56
71
/**
57
72
* Creates a filter that matches all documents where the value of the field name equals the specified value. Note that this does
58
73
* actually generate a $eq operator, as the query language doesn't require it.
Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification {
78
78
def ' eq' () {
79
79
expect :
80
80
find(eq(' x' , 1 )) == [a]
81
+ find(eq(2 )) == [b]
81
82
}
82
83
83
84
def ' $ne' () {
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ class FiltersSpecification extends Specification {
80
80
expect :
81
81
toBson(eq(' x' , 1 )) == parse(' {x : 1}' )
82
82
toBson(eq(' x' , null )) == parse(' {x : null}' )
83
+ toBson(eq(1 )) == parse(' {_id : 1}' )
83
84
}
84
85
85
86
def ' should render $ne' () {
You can’t perform that action at this time.
0 commit comments