Packages

object Filters

A factory for query filters. A convenient way to use this class is to statically import all of its methods, which allows usage like:

collection.find(and(eq("x", 1), lt("y", 3)))

Since

1.0

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Filters
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def all[TItem](fieldName: String, values: TItem*): Bson

    Creates a filter that matches all documents where the value of a field is an array that contains all the specified values.

    Creates a filter that matches all documents where the value of a field is an array that contains all the specified values.

    TItem

    the value type

    fieldName

    the field name

    values

    the list of values

    returns

    the filter

    See also

    $all

  5. def and(filters: Bson*): Bson

    Creates a filter that performs a logical AND of the provided list of filters.

    Creates a filter that performs a logical AND of the provided list of filters. Note that this will only generate a "$and" operator if absolutely necessary, as the query language implicity ands together all the keys. In other words, a query expression like:

    and(eq("x", 1), lt("y", 3))
    

    will generate a MongoDB query like:

    {x : 1, y : {$lt : 3}}
    

    filters

    the list of filters to and together

    returns

    the filter

    See also

    $and

  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def bitsAllClear(fieldName: String, bitmask: Long): Bson

    Creates a filter that matches all documents where all of the bit positions are clear in the field.

    Creates a filter that matches all documents where all of the bit positions are clear in the field.

    fieldName

    the field name

    bitmask

    the bitmask

    returns

    the filter

    Since

    1.1

    Note

    Requires MongoDB 3.2 or greater

    See also

    $bitsAllClear

  8. def bitsAllSet(fieldName: String, bitmask: Long): Bson

    Creates a filter that matches all documents where all of the bit positions are set in the field.

    Creates a filter that matches all documents where all of the bit positions are set in the field.

    fieldName

    the field name

    bitmask

    the bitmask

    returns

    the filter

    Since

    1.1

    Note

    Requires MongoDB 3.2 or greater

    See also

    $bitsAllSet

  9. def bitsAnyClear(fieldName: String, bitmask: Long): Bson

    Creates a filter that matches all documents where any of the bit positions are clear in the field.

    Creates a filter that matches all documents where any of the bit positions are clear in the field.

    fieldName

    the field name

    bitmask

    the bitmask

    returns

    the filter

    Since

    1.1

    Note

    Requires MongoDB 3.2 or greater

    See also

    $bitsAnyClear

  10. def bitsAnySet(fieldName: String, bitmask: Long): Bson

    Creates a filter that matches all documents where any of the bit positions are set in the field.

    Creates a filter that matches all documents where any of the bit positions are set in the field.

    fieldName

    the field name

    bitmask

    the bitmask

    returns

    the filter

    Since

    1.1

    Note

    Requires MongoDB 3.2 or greater

    See also

    $bitsAnySet

  11. def bsonType(fieldName: String, bsonType: BsonType): Bson

    Creates a filter that matches all documents where the value of the field is of the specified BSON type.

    Creates a filter that matches all documents where the value of the field is of the specified BSON type.

    A friendly alias for the type method.

    fieldName

    the field name

    bsonType

    the BSON type

    returns

    the filter

    See also

    $type

  12. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  13. def elemMatch(fieldName: String, filter: Bson): Bson

    Creates a filter that matches all documents containing a field that is an array where at least one member of the array matches the given filter.

    Creates a filter that matches all documents containing a field that is an array where at least one member of the array matches the given filter.

    fieldName

    the field name

    filter

    the filter to apply to each element

    returns

    the filter

    See also

    $elemMatch

  14. def eq[TItem](fieldName: String, value: TItem): Bson

    Creates a filter that matches all documents where the value of the field name equals the specified value.

    Creates a filter that matches all documents where the value of the field name equals the specified value. Note that this does actually generate a $eq operator, as the query language doesn't require it.

    TItem

    the value type

    fieldName

    the field name

    value

    the value

    returns

    the filter

    See also

    $eq

  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def equal[TItem](fieldName: String, value: TItem): Bson

    Creates a filter that matches all documents where the value of the field name equals the specified value.

    Creates a filter that matches all documents where the value of the field name equals the specified value. Note that this does actually generate a $eq operator, as the query language doesn't require it.

    A friendly alias for the eq method.

    TItem

    the value type

    fieldName

    the field name

    value

    the value

    returns

    the filter

    See also

    $eq

  17. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  18. def exists(fieldName: String, exists: Boolean): Bson

    Creates a filter that matches all documents that either contain or do not contain the given field, depending on the value of the exists parameter.

    Creates a filter that matches all documents that either contain or do not contain the given field, depending on the value of the exists parameter.

    fieldName

    the field name

    exists

    true to check for existence, false to check for absence

    returns

    the filter

    See also

    $exists

  19. def exists(fieldName: String): Bson

    Creates a filter that matches all documents that contain the given field.

    Creates a filter that matches all documents that contain the given field.

    fieldName

    the field name

    returns

    the filter

    See also

    $exists

  20. def expr[TExpression](expression: TExpression): Bson

    Allows the use of aggregation expressions within the query language.

    Allows the use of aggregation expressions within the query language.

    TExpression

    the expression type

    expression

    the aggregation expression

    returns

    the filter

    Since

    2.2

    Note

    Requires MongoDB 3.6 or greater

  21. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  22. def geoIntersects(fieldName: String, geometry: Geometry): Bson

    Creates a filter that matches all documents containing a field with geospatial data that intersects with the specified shape.

    Creates a filter that matches all documents containing a field with geospatial data that intersects with the specified shape.

    fieldName

    the field name

    geometry

    the bounding GeoJSON geometry object

    returns

    the filter

    See also

    $geoIntersects

  23. def geoIntersects(fieldName: String, geometry: Bson): Bson

    Creates a filter that matches all documents containing a field with geospatial data that intersects with the specified shape.

    Creates a filter that matches all documents containing a field with geospatial data that intersects with the specified shape.

    fieldName

    the field name

    geometry

    the bounding GeoJSON geometry object

    returns

    the filter

    See also

    $geoIntersects

  24. def geoWithin(fieldName: String, geometry: Bson): Bson

    Creates a filter that matches all documents containing a field with geospatial data that exists entirely within the specified shape.

    Creates a filter that matches all documents containing a field with geospatial data that exists entirely within the specified shape.

    fieldName

    the field name

    geometry

    the bounding GeoJSON geometry object

    returns

    the filter

    See also

    $geoWithin

  25. def geoWithin(fieldName: String, geometry: Geometry): Bson

    Creates a filter that matches all documents containing a field with geospatial data that exists entirely within the specified shape.

    Creates a filter that matches all documents containing a field with geospatial data that exists entirely within the specified shape.

    fieldName

    the field name

    geometry

    the bounding GeoJSON geometry object

    returns

    the filter

    See also

    $geoWithin

  26. def geoWithinBox(fieldName: String, lowerLeftX: Double, lowerLeftY: Double, upperRightX: Double, upperRightY: Double): Bson

    Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified box.

    Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified box.

    fieldName

    the field name

    lowerLeftX

    the lower left x coordinate of the box

    lowerLeftY

    the lower left y coordinate of the box

    upperRightX

    the upper left x coordinate of the box

    upperRightY

    the upper left y coordinate of the box

    returns

    the filter

    See also

    $box

    $geoWithin

  27. def geoWithinCenter(fieldName: String, x: Double, y: Double, radius: Double): Bson

    Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified circle.

    Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified circle.

    fieldName

    the field name

    x

    the x coordinate of the circle

    y

    the y coordinate of the circle

    radius

    the radius of the circle, as measured in the units used by the coordinate system

    returns

    the filter

    See also

    $center

    $geoWithin

  28. def geoWithinCenterSphere(fieldName: String, x: Double, y: Double, radius: Double): Bson

    Creates a filter that matches all documents containing a field with geospatial data (GeoJSON or legacy coordinate pairs) that exist entirely within the specified circle, using spherical geometry.

    Creates a filter that matches all documents containing a field with geospatial data (GeoJSON or legacy coordinate pairs) that exist entirely within the specified circle, using spherical geometry. If using longitude and latitude, specify longitude first.

    fieldName

    the field name

    x

    the x coordinate of the circle

    y

    the y coordinate of the circle

    radius

    the radius of the circle, in radians

    returns

    the filter

    See also

    $centerSphere

    $geoWithin

  29. def geoWithinPolygon(fieldName: String, points: Seq[Seq[Double]]): Bson

    Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified polygon.

    Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified polygon.

    fieldName

    the field name

    points

    a Seq of pairs of x, y coordinates. Any extra dimensions are ignored

    returns

    the filter

    See also

    $polygon

    $geoWithin

  30. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  31. def gt[TItem](fieldName: String, value: TItem): Bson

    Creates a filter that matches all documents where the value of the given field is greater than the specified value.

    Creates a filter that matches all documents where the value of the given field is greater than the specified value.

    TItem

    the value type

    fieldName

    the field name

    value

    the value

    returns

    the filter

    See also

    $gt

  32. def gte[TItem](fieldName: String, value: TItem): Bson

    Creates a filter that matches all documents where the value of the given field is greater than or equal to the specified value.

    Creates a filter that matches all documents where the value of the given field is greater than or equal to the specified value.

    TItem

    the value type

    fieldName

    the field name

    value

    the value

    returns

    the filter

    See also

    $gte

  33. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  34. def in[TItem](fieldName: String, values: TItem*): Bson

    Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.

    Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.

    TItem

    the value type

    fieldName

    the field name

    values

    the list of values

    returns

    the filter

    See also

    $in

  35. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  36. def jsonSchema(schema: Bson): Bson

    Creates a filter that matches all documents that validate against the given JSON schema document.

    Creates a filter that matches all documents that validate against the given JSON schema document.

    schema

    the JSON schema to validate against

    returns

    the filter

    Since

    2.2

    Note

    Requires MongoDB 3.6 or greater

  37. def lt[TItem](fieldName: String, value: TItem): Bson

    Creates a filter that matches all documents where the value of the given field is less than the specified value.

    Creates a filter that matches all documents where the value of the given field is less than the specified value.

    TItem

    the value type

    fieldName

    the field name

    value

    the value

    returns

    the filter

    See also

    $lt

  38. def lte[TItem](fieldName: String, value: TItem): Bson

    Creates a filter that matches all documents where the value of the given field is less than or equal to the specified value.

    Creates a filter that matches all documents where the value of the given field is less than or equal to the specified value.

    TItem

    the value type

    fieldName

    the field name

    value

    the value

    returns

    the filter

    See also

    $lte

  39. def mod(fieldName: String, divisor: Long, remainder: Long): Bson

    Creates a filter that matches all documents where the value of a field divided by a divisor has the specified remainder (i.e.

    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).

    fieldName

    the field name

    divisor

    the modulus

    remainder

    the remainder

    returns

    the filter

    See also

    $mod

  40. def ne[TItem](fieldName: String, value: TItem): Bson

    Creates a filter that matches all documents where the value of the field name does not equal the specified value.

    Creates a filter that matches all documents where the value of the field name does not equal the specified value.

    TItem

    the value type

    fieldName

    the field name

    value

    the value

    returns

    the filter

    See also

    $ne

  41. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  42. def near(fieldName: String, x: Double, y: Double, maxDistance: Option[Double], minDistance: Option[Double]): Bson

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified point.

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified point.

    fieldName

    the field name

    x

    the x coordinate

    y

    the y coordinate

    maxDistance

    the optional maximum distance from the point, in radians

    minDistance

    the optional minimum distance from the point, in radians

    returns

    the filter

    See also

    $near

  43. def near(fieldName: String, x: Double, y: Double): Bson

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified point.

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified point.

    fieldName

    the field name

    x

    the x coordinate

    y

    the y coordinate

    returns

    the filter

    See also

    $near

  44. def near(fieldName: String, geometry: Bson, maxDistance: Option[Double], minDistance: Option[Double]): Bson

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.

    fieldName

    the field name

    geometry

    the bounding GeoJSON geometry object

    maxDistance

    the optional maximum distance from the point, in meters

    minDistance

    the optional minimum distance from the point, in meters

    returns

    the filter

    See also

    $near

  45. def near(fieldName: String, geometry: Bson): Bson

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.

    fieldName

    the field name

    geometry

    the bounding GeoJSON geometry object

    returns

    the filter

    See also

    $near

  46. def near(fieldName: String, geometry: Point, maxDistance: Option[Double], minDistance: Option[Double]): Bson

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.

    fieldName

    the field name

    geometry

    the bounding GeoJSON geometry object

    maxDistance

    the optional maximum distance from the point, in meters

    minDistance

    the optional minimum distance from the point, in meters

    returns

    the filter

    See also

    $near

  47. def near(fieldName: String, geometry: Point): Bson

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.

    fieldName

    the field name

    geometry

    the bounding GeoJSON geometry object

    returns

    the filter

    See also

    $near

  48. def nearSphere(fieldName: String, x: Double, y: Double, maxDistance: Option[Double], minDistance: Option[Double]): Bson

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified point using spherical geometry.

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified point using spherical geometry.

    fieldName

    the field name

    x

    the x coordinate

    y

    the y coordinate

    maxDistance

    the optional maximum distance from the point, in radians

    minDistance

    the optional minimum distance from the point, in radians

    returns

    the filter

    See also

    $near

  49. def nearSphere(fieldName: String, x: Double, y: Double): Bson

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified point using spherical geometry.

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified point using spherical geometry.

    fieldName

    the field name

    x

    the x coordinate

    y

    the y coordinate

    returns

    the filter

    See also

    $near

  50. def nearSphere(fieldName: String, geometry: Bson, maxDistance: Option[Double], minDistance: Option[Double]): Bson

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point using spherical geometry.

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point using spherical geometry.

    fieldName

    the field name

    geometry

    the bounding GeoJSON geometry object

    maxDistance

    the optional maximum distance from the point, in meters

    minDistance

    the optional minimum distance from the point, in meters

    returns

    the filter

    See also

    $near

  51. def nearSphere(fieldName: String, geometry: Bson): Bson

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point using spherical geometry.

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point using spherical geometry.

    fieldName

    the field name

    geometry

    the bounding GeoJSON geometry object

    returns

    the filter

    See also

    $near

  52. def nearSphere(fieldName: String, geometry: Point, maxDistance: Option[Double], minDistance: Option[Double]): Bson

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point using spherical geometry.

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point using spherical geometry.

    fieldName

    the field name

    geometry

    the bounding GeoJSON geometry object

    maxDistance

    the optional maximum distance from the point, in meters

    minDistance

    the optional minimum distance from the point, in meters

    returns

    the filter

    See also

    $near

  53. def nearSphere(fieldName: String, geometry: Point): Bson

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point using spherical geometry.

    Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point using spherical geometry.

    fieldName

    the field name

    geometry

    the bounding GeoJSON geometry object

    returns

    the filter

    See also

    $near

  54. def nin[TItem](fieldName: String, values: TItem*): Bson

    Creates a filter that matches all documents where the value of a field does not equal any of the specified values or does not exist.

    Creates a filter that matches all documents where the value of a field does not equal any of the specified values or does not exist.

    TItem

    the value type

    fieldName

    the field name

    values

    the list of values

    returns

    the filter

    See also

    $nin

  55. def nor(filters: Bson*): Bson

    Creates a filter that performs a logical NOR operation on all the specified filters.

    Creates a filter that performs a logical NOR operation on all the specified filters.

    filters

    the list of values

    returns

    the filter

    See also

    $nor

  56. def not(filter: Bson): Bson

    Creates a filter that matches all documents that do not match the passed in filter.

    Creates a filter that matches all documents that do not match the passed in filter. Requires the field name to passed as part of the value passed in and lifts it to create a valid "$not" query:

    not(eq("x", 1))

    will generate a MongoDB query like: {x :$not: {$eq : 1}}

    filter

    the value

    returns

    the filter

    See also

    $not

  57. def notEqual[TItem](fieldName: String, value: TItem): Bson

    Creates a filter that matches all documents where the value of the field name does not equal the specified value.

    Creates a filter that matches all documents where the value of the field name does not equal the specified value.

    A friendly alias for the neq method.

    TItem

    the value type

    fieldName

    the field name

    value

    the value

    returns

    the filter

    See also

    $ne

  58. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  59. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  60. def or(filters: Bson*): Bson

    Creates a filter that preforms a logical OR of the provided list of filters.

    Creates a filter that preforms a logical OR of the provided list of filters.

    filters

    the list of filters to and together

    returns

    the filter

    See also

    $or

  61. def regex(fieldName: String, regex: Regex): Bson

    Creates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.

    Creates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.

    fieldName

    the field name

    regex

    the regex

    returns

    the filter

    Since

    1.0

    See also

    $regex

  62. def regex(fieldName: String, pattern: String, options: String): Bson

    Creates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.

    Creates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.

    fieldName

    the field name

    pattern

    the pattern

    options

    the options

    returns

    the filter

    See also

    $regex

  63. def regex(fieldName: String, pattern: String): Bson

    Creates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.

    Creates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.

    fieldName

    the field name

    pattern

    the pattern

    returns

    the filter

    See also

    $regex

  64. def size(fieldName: String, size: Int): Bson

    Creates a filter that matches all documents where the value of a field is an array of the specified size.

    Creates a filter that matches all documents where the value of a field is an array of the specified size.

    fieldName

    the field name

    size

    the size of the array

    returns

    the filter

    See also

    $size

  65. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  66. def text(search: String, textSearchOptions: TextSearchOptions): Bson

    Creates a filter that matches all documents matching the given search term using the given language.

    Creates a filter that matches all documents matching the given search term using the given language.

    search

    the search term

    textSearchOptions

    the text search options to use

    returns

    the filter

    Since

    1.1

    See also

    $text

  67. def text(search: String): Bson

    Creates a filter that matches all documents matching the given search term.

    Creates a filter that matches all documents matching the given search term.

    search

    the search term

    returns

    the filter

    See also

    $text

  68. def toString(): String
    Definition Classes
    AnyRef → Any
  69. def type(fieldName: String, bsonType: BsonType): Bson

    Creates a filter that matches all documents where the value of the field is of the specified BSON type.

    Creates a filter that matches all documents where the value of the field is of the specified BSON type.

    fieldName

    the field name

    bsonType

    the BSON type

    returns

    the filter

    See also

    $type

  70. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  71. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  72. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  73. def where(javaScriptExpression: String): Bson

    Creates a filter that matches all documents for which the given expression is true.

    Creates a filter that matches all documents for which the given expression is true.

    javaScriptExpression

    the JavaScript expression

    returns

    the filter

    See also

    $where

Deprecated Value Members

  1. def text(search: String, language: String): Bson

    Creates a filter that matches all documents matching the given search term using the given language.

    Creates a filter that matches all documents matching the given search term using the given language.

    search

    the search term

    language

    the language to use for stop words

    returns

    the filter

    Annotations
    @Deprecated
    Deprecated

    use

    Filters.text(String, TextSearchOptions)
    See also

    $text

Inherited from AnyRef

Inherited from Any

Ungrouped