@@ -25,6 +25,7 @@ import org.bson.BsonType
25
25
import org.bson.Document
26
26
import org.bson.conversions.Bson
27
27
import java.util.regex.Pattern
28
+ import kotlin.internal.OnlyInputTypes
28
29
import kotlin.reflect.KProperty
29
30
30
31
/* *
@@ -34,9 +35,9 @@ import kotlin.reflect.KProperty
34
35
* @param value the value
35
36
* @param <T> the value type
36
37
* @return the filter
37
- * @mongodb.driver .manual reference/operator/query/eq $eq
38
+ * @mongodb.driveDr .manual reference/operator/query/eq $eq
38
39
*/
39
- infix fun <T > KProperty<T>.eq (value : T ): Bson = Filters .eq(path(), value)
40
+ infix fun <@ OnlyInputTypes T , V : T > KProperty<T? >.eq (value : V ): Bson = Filters .eq(path(), value)
40
41
41
42
/* *
42
43
* Creates a filter that matches all documents where the value of the property contains the specified value. Note that this doesn't
@@ -52,7 +53,7 @@ infix fun <T> KProperty<T>.eq(value: T): Bson = Filters.eq(path(), value)
52
53
* @return the filter
53
54
* @mongodb.driver.manual reference/operator/query/eq/#op._S_eq
54
55
*/
55
- infix fun <T > KProperty<Collection<T >?>.contains (value : T ): Bson = Filters .eq(path(), value)
56
+ infix fun <@ OnlyInputTypes T > KProperty<Iterable<T? >?>.contains (value : T ): Bson = Filters .eq(path(), value)
56
57
57
58
/* *
58
59
* Creates a filter that matches all documents where the value of the field name does not equal the specified value.
@@ -62,7 +63,7 @@ infix fun <T> KProperty<Collection<T>?>.contains(value: T): Bson = Filters.eq(pa
62
63
* @return the filter
63
64
* @mongodb.driver.manual reference/operator/query/ne $ne
64
65
*/
65
- infix fun <T > KProperty<T>.ne (value : T ): Bson = Filters .ne(path(), value)
66
+ infix fun <@ OnlyInputTypes T > KProperty<T? >.ne (value : T ): Bson = Filters .ne(path(), value)
66
67
67
68
/* *
68
69
* Creates a filter that matches all documents where the value of the given property is less than the specified value.
@@ -72,7 +73,7 @@ infix fun <T> KProperty<T>.ne(value: T): Bson = Filters.ne(path(), value)
72
73
* @return the filter
73
74
* @mongodb.driver.manual reference/operator/query/lt $lt
74
75
*/
75
- infix fun <T > KProperty<T>.lt (item : T ): Bson = Filters .lt(path(), item)
76
+ infix fun <@ OnlyInputTypes T > KProperty<T? >.lt (item : T ): Bson = Filters .lt(path(), item)
76
77
77
78
/* *
78
79
* Creates a filter that matches all documents where the value of the given property is greater than the specified value.
@@ -82,7 +83,7 @@ infix fun <T> KProperty<T>.lt(item: T): Bson = Filters.lt(path(), item)
82
83
* @return the filter
83
84
* @mongodb.driver.manual reference/operator/query/gt $gt
84
85
*/
85
- infix fun <T > KProperty<T>.gt (value : T ): Bson = Filters .gt(path(), value)
86
+ infix fun <@ OnlyInputTypes T > KProperty<T? >.gt (value : T ): Bson = Filters .gt(path(), value)
86
87
87
88
/* *
88
89
* Creates a filter that matches all documents where the value of the given property is less than or equal to the specified value.
@@ -92,7 +93,7 @@ infix fun <T> KProperty<T>.gt(value: T): Bson = Filters.gt(path(), value)
92
93
* @return the filter
93
94
* @mongodb.driver.manual reference/operator/query/lte $lte
94
95
*/
95
- infix fun <T > KProperty<T>.lte (value : T ): Bson = Filters .lte(path(), value)
96
+ infix fun <@ OnlyInputTypes T > KProperty<T? >.lte (value : T ): Bson = Filters .lte(path(), value)
96
97
97
98
/* *
98
99
* Creates a filter that matches all documents where the value of the given property is greater than or equal to the specified value.
@@ -102,7 +103,7 @@ infix fun <T> KProperty<T>.lte(value: T): Bson = Filters.lte(path(), value)
102
103
* @return the filter
103
104
* @mongodb.driver.manual reference/operator/query/gte $gte
104
105
*/
105
- infix fun <T > KProperty<T>.gte (value : T ): Bson = Filters .gte(path(), value)
106
+ infix fun <@ OnlyInputTypes T > KProperty<T? >.gte (value : T ): Bson = Filters .gte(path(), value)
106
107
107
108
/* *
108
109
* Creates a filter that matches all documents where the value of a property equals any value in the list of specified values.
@@ -112,7 +113,7 @@ infix fun <T> KProperty<T>.gte(value: T): Bson = Filters.gte(path(), value)
112
113
* @return the filter
113
114
* @mongodb.driver.manual reference/operator/query/in $in
114
115
*/
115
- infix fun <T > KProperty <T >.`in` (values : Iterable <T >): Bson = Filters .`in `(path(), values)
116
+ infix fun <@ OnlyInputTypes T > KProperty <T ? >.`in` (values : Iterable <T >): Bson = Filters .`in `(path(), values)
116
117
117
118
/* *
118
119
* Creates a filter that matches all documents where the value of a property equals any value in the list of specified values.
@@ -122,7 +123,8 @@ infix fun <T> KProperty<T>.`in`(values: Iterable<T>): Bson = Filters.`in`(path()
122
123
* @return the filter
123
124
* @mongodb.driver.manual reference/operator/query/in $in
124
125
*/
125
- infix fun <T > KProperty<T>.contains (values : Iterable <T >): Bson = `in `(values)
126
+ @JvmName(" inArray" )
127
+ infix fun <@OnlyInputTypes T > KProperty <Iterable <T >? >.`in` (values : Iterable <T >): Bson = Filters .`in `(path(), values)
126
128
127
129
/* *
128
130
* Creates a filter that matches all documents where the value of a property does not equal any of the specified values or does not exist.
@@ -132,7 +134,19 @@ infix fun <T> KProperty<T>.contains(values: Iterable<T>): Bson = `in`(values)
132
134
* @return the filter
133
135
* @mongodb.driver.manual reference/operator/query/nin $nin
134
136
*/
135
- infix fun <T > KProperty<T>.nin (values : Iterable <T >): Bson = Filters .nin(path(), values)
137
+ infix fun <@OnlyInputTypes T > KProperty<T?>.nin (values : Iterable <T >): Bson = Filters .nin(path(), values)
138
+
139
+ /* *
140
+ * Creates a filter that matches all documents where the value of a property does not equal any of the specified values or does not exist.
141
+ *
142
+ * @param values the list of values
143
+ * @param <T> the value type
144
+ * @return the filter
145
+ * @mongodb.driver.manual reference/operator/query/nin $nin
146
+ */
147
+ @JvmName(" ninArray" )
148
+ infix fun <@OnlyInputTypes T > KProperty<Iterable<T>?>.nin (values : Iterable <T >): Bson = Filters .nin(path(), values)
149
+
136
150
137
151
/* *
138
152
* Creates a filter that performs a logical AND of the provided list of filters. Note that this will only generate a "$and"
@@ -355,7 +369,7 @@ fun <TExpression> expr(expression: TExpression): Bson = Filters.expr(expression)
355
369
* @return the filter
356
370
* @mongodb.driver.manual reference/operator/query/all $all
357
371
*/
358
- infix fun <T > KProperty<T >.all (values : Iterable <T >): Bson = Filters .all(path(), values)
372
+ infix fun <@ OnlyInputTypes T > KProperty<Iterable<T>? >.all (values : Iterable <T >): Bson = Filters .all(path(), values)
359
373
360
374
/* *
361
375
* Creates a filter that matches all documents where the value of a property is an array that contains all the specified values.
@@ -365,7 +379,7 @@ infix fun <T> KProperty<T>.all(values: Iterable<T>): Bson = Filters.all(path(),
365
379
* @return the filter
366
380
* @mongodb.driver.manual reference/operator/query/all $all
367
381
*/
368
- fun <T > KProperty<T >.all (vararg values : T ): Bson = Filters .all(path(), * values)
382
+ fun <@ OnlyInputTypes T > KProperty<Iterable<T>? >.all (vararg values : T ): Bson = Filters .all(path(), * values)
369
383
370
384
/* *
371
385
* Creates a filter that matches all documents containing a property that is an array where at least one member of the array matches the
@@ -375,7 +389,7 @@ fun <T> KProperty<T>.all(vararg values: T): Bson = Filters.all(path(), *values)
375
389
* @return the filter
376
390
* @mongodb.driver.manual reference/operator/query/elemMatch $elemMatch
377
391
*/
378
- infix fun <T > KProperty<Collection <T>>.elemMatch (filter : Bson ): Bson = Filters .elemMatch(path(), filter)
392
+ infix fun <T > KProperty<Iterable <T>>.elemMatch (filter : Bson ): Bson = Filters .elemMatch(path(), filter)
379
393
380
394
/* *
381
395
* Creates a filter that matches all documents where the value of a property is an array of the specified size.
0 commit comments