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 {
5353 private Filters () {
5454 }
5555
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+
5671 /**
5772 * Creates a filter that matches all documents where the value of the field name equals the specified value. Note that this does
5873 * 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 {
7878 def ' eq' () {
7979 expect :
8080 find(eq(' x' , 1 )) == [a]
81+ find(eq(2 )) == [b]
8182 }
8283
8384 def ' $ne' () {
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ class FiltersSpecification extends Specification {
8080 expect :
8181 toBson(eq(' x' , 1 )) == parse(' {x : 1}' )
8282 toBson(eq(' x' , null )) == parse(' {x : null}' )
83+ toBson(eq(1 )) == parse(' {_id : 1}' )
8384 }
8485
8586 def ' should render $ne' () {
You can’t perform that action at this time.
0 commit comments