MongoFilters
Definition of the filters in Bson that are used in MongoDB collection operations.
all
all(fieldName: string, values: java.lang.Object[]) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the array field contains all the given values.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| values | java.lang.Object[] | Values that the array must contain. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
all(fieldName: string, values: Values | DataSchema | java.lang.Iterable) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the array field contains all the given values.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| values | Values | DataSchema | java.lang.Iterable |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
and
and(filters: org.bson.conversions.Bson[]) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where all the given conditions are true (logical AND).
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filters | org.bson.conversions.Bson[] | Filters to combine with logical AND. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
and(filters: Values | DataSchema | java.lang.Iterable) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where all the given conditions are true (logical AND).
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filters | Values | DataSchema | java.lang.Iterable |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
empty
empty() : org.bson.conversions.Bson
Description
Creates an empty filter that matches all documents in the collection.
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
eq
eq(value: java.lang.Object) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value equals the specified value.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| value | java.lang.Object | Value to compare. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
eq(fieldName: string, value: java.lang.Object) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of the specified field equals the given value.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| value | java.lang.Object | Value to compare. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
exists
exists(fieldName: string) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the specified field exists.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
exists(fieldName: string, exists: boolean) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the specified field exists or does not exist, according to the given flag.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| exists | boolean | True to check if the field exists, false to check if it does not exist. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
gt
gt(fieldName: string, value: java.lang.Object) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of the specified field is greater than the given value.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| value | java.lang.Object | Value to compare. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
gte
gte(fieldName: string, value: java.lang.Object) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of the specified field is greater than or equal to the given value.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| value | java.lang.Object | Value to compare. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
in
in(fieldName: string, values: java.lang.Object[]) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of the specified field matches any of the given values.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| values | java.lang.Object[] | Values to compare. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
in(fieldName: string, values: Values | DataSchema | java.lang.Iterable) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of the specified field matches any of the given values in the iterable.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| values | Values | DataSchema | java.lang.Iterable |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
lt
lt(fieldName: string, value: java.lang.Object) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of the specified field is less than the given value.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| value | java.lang.Object | Value to compare. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
lte
lte(fieldName: string, value: java.lang.Object) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of the specified field is less than or equal to the given value.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| value | java.lang.Object | Value to compare. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
mod
mod(fieldName: string, divisor: long, remainder: long) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of a field divided by a divisor has the specified remainder (i.e. perform a modulo operation to select documents).
How To Use
_mongo.filters().mod('quantity', 5, 2);
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| divisor | long | The modulus of the operation. |
| remainder | long | The remainder of the operation. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
ne
ne(fieldName: string, value: java.lang.Object) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of the specified field does not equal the given value.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| value | java.lang.Object | Value to compare. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
nin
nin(fieldName: string, values: java.lang.Object[]) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of the specified field does not match any of the given values.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| values | java.lang.Object[] | Values to compare. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
nin(fieldName: string, values: Values | DataSchema | java.lang.Iterable) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of the specified field does not match any of the given values in the iterable.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| values | Values | DataSchema | java.lang.Iterable |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
nor
nor(filters: org.bson.conversions.Bson[]) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where none of the given conditions are true (logical NOR).
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filters | org.bson.conversions.Bson[] | Filters to combine with logical NOR. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
nor(filters: Values | DataSchema | java.lang.Iterable) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where none of the given conditions are true (logical NOR).
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filters | Values | DataSchema | java.lang.Iterable |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
not
not(filter: org.bson.conversions.Bson) : org.bson.conversions.Bson
Description
Creates a filter that negates the given filter (logical NOT).
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | Filter to negate. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
or
or(filters: org.bson.conversions.Bson[]) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where at least one of the given conditions is true (logical OR).
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filters | org.bson.conversions.Bson[] | Filters to combine with logical OR. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
or(filters: Values | DataSchema | java.lang.Iterable) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where at least one of the given conditions is true (logical OR).
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filters | Values | DataSchema | java.lang.Iterable |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
regex
regex(fieldName: string, pattern: string) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of the field matches the given regular expression pattern.
How To Use
_mongo.filters().regex('fieldName', 'regex');
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| pattern | string | Regular expression. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
regex(fieldName: string, pattern: string, options: string) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.
How To Use
_mongo.filters().regex('fieldName', 'regex', 'i');
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| pattern | string | Regular expression. |
| options | string | Regex options. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
regex(fieldName: string, pattern: java.util.regex.Pattern) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of the specified field matches the given regular expression pattern.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| pattern | java.util.regex.Pattern | Regular expression pattern. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
size
size(fieldName: string, size: int) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the value of a field is an array of the specified size.
How To Use
_mongo.filters().size('fieldName', '3');
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| size | int | Size of the array. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
text
text(search: string) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents for which the given text search expression matches.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| search | string | Text to search for. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
text(search: string, textSearchOptions: com.mongodb.client.model.TextSearchOptions) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents for which the given text search expression matches, with the specified text search options.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| search | string | Text to search for. |
| textSearchOptions | com.mongodb.client.model.TextSearchOptions | Text search options. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
type
type(fieldName: string, type: string) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the specified field is of the type indicated by the string.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| type | string | Field type as string. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
type(fieldName: string, type: org.bson.BsonType) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents where the specified field is of the given BsonType.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fieldName | string | Document field name. |
| type | org.bson.BsonType | BsonType of the field. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.
where
where(javaScriptExpression: string) : org.bson.conversions.Bson
Description
Creates a filter that matches all documents for which the given expression is true.
How To Use
_mongo.filters().where('javascript-expression');
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| javaScriptExpression | string | JavaScript expression. |
Return
( org.bson.conversions.Bson )
Returns a filter in Bson format.