Object

org.mongodb.scala.model

Filters

Related Doc: package model

Permalink

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def all[TItem](fieldName: String, values: TItem*): Bson

    Permalink

    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

    Permalink

    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

    Permalink
    Definition Classes
    Any
  7. def bsonType(fieldName: String, bsonType: BsonType): Bson

    Permalink

    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

  8. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def elemMatch(fieldName: String, filter: Bson): Bson

    Permalink

    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

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

    Permalink

    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

  11. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  12. def equal[TItem](fieldName: String, value: TItem): Bson

    Permalink

    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

  13. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  14. def exists(fieldName: String, exists: Boolean): Bson

    Permalink

    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

  15. def exists(fieldName: String): Bson

    Permalink

    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

  16. def finalize(): Unit

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

  25. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  26. def gt[TItem](fieldName: String, value: TItem): Bson

    Permalink

    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

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

    Permalink

    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

  28. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  29. def in[TItem](fieldName: String, values: TItem*): Bson

    Permalink

    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

  30. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  31. def lt[TItem](fieldName: String, value: TItem): Bson

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

  35. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  36. def near(fieldName: String, x: Double, y: Double, maxDistance: Option[Double], minDistance: Option[Double]): Bson

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

  50. def not(filter: Bson): Bson

    Permalink

    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

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

    Permalink

    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

  52. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  53. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  54. def or(filters: Bson*): Bson

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

  59. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  60. def text(search: String, language: String): Bson

    Permalink

    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

    See also

    $text

  61. def text(search: String): Bson

    Permalink

    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

  62. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  63. def type(fieldName: String, bsonType: BsonType): Bson

    Permalink

    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

  64. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  65. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  66. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  67. def where(javaScriptExpression: String): Bson

    Permalink

    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

Inherited from AnyRef

Inherited from Any

Ungrouped