Packages

object Aggregates

Builders for aggregation pipeline stages.

Since

1.0

See also

Aggregation pipeline

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

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 addFields(fields: Field[_]*): Bson

    Creates an $addFields pipeline stage

    Creates an $addFields pipeline stage

    fields

    the fields to add

    returns

    the $addFields pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 3.4 or greater

    See also

    $addFields

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def bucket[TExpression, TBoundary](groupBy: TExpression, options: BucketOptions, boundaries: TBoundary*): Bson

    Creates a $bucket pipeline stage

    Creates a $bucket pipeline stage

    TExpression

    the groupBy expression type

    TBoundary

    the boundary type

    groupBy

    the criteria to group By

    options

    the optional values for the $bucket stage

    boundaries

    the boundaries of the buckets

    returns

    the $bucket pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 3.4 or greater

    See also

    $bucket

  7. def bucket[TExpression, TBoundary](groupBy: TExpression, boundaries: TBoundary*): Bson

    Creates a $bucket pipeline stage

    Creates a $bucket pipeline stage

    TExpression

    the groupBy expression type

    TBoundary

    the boundary type

    groupBy

    the criteria to group By

    boundaries

    the boundaries of the buckets

    returns

    the $bucket pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 3.4 or greater

    See also

    $bucket

  8. def bucketAuto[TExpression, TBoundary](groupBy: TExpression, buckets: Int, options: BucketAutoOptions): Bson

    Creates a $bucketAuto pipeline stage

    Creates a $bucketAuto pipeline stage

    TExpression

    the groupBy expression type

    groupBy

    the criteria to group By

    buckets

    the number of the buckets

    options

    the optional values for the $bucketAuto stage

    returns

    the $bucketAuto pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 3.4 or greater

    See also

    $bucketAuto

  9. def bucketAuto[TExpression, TBoundary](groupBy: TExpression, buckets: Int): Bson

    Creates a $bucketAuto pipeline stage

    Creates a $bucketAuto pipeline stage

    TExpression

    the groupBy expression type

    groupBy

    the criteria to group By

    buckets

    the number of the buckets

    returns

    the $bucketAuto pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 3.4 or greater

    See also

    $bucketAuto

  10. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  11. def count(field: String): Bson

    Creates a $count pipeline stage using the named field to store the result

    Creates a $count pipeline stage using the named field to store the result

    field

    the field in which to store the count

    returns

    the $count pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 3.4 or greater

    See also

    $count

  12. def count(): Bson

    Creates a $count pipeline stage using the field name "count" to store the result

    Creates a $count pipeline stage using the field name "count" to store the result

    returns

    the $count pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 3.4 or greater

    See also

    $count

  13. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  15. def facet(facets: Facet*): Bson

    Creates a $facet pipeline stage

    Creates a $facet pipeline stage

    facets

    the facets to use

    returns

    the new pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 3.4 or greater

    See also

    $facet

  16. def filter(filter: Bson): Bson

    Creates a $match pipeline stage for the specified filter

    Creates a $match pipeline stage for the specified filter

    A friendly alias for the match method.

    filter

    the filter to match against

    returns

    the $match pipeline stage

    See also

    Filters

    $match

  17. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  18. def graphLookup[TExpression](from: String, startWith: TExpression, connectFromField: String, connectToField: String, as: String, options: GraphLookupOptions): Bson

    Creates a graphLookup pipeline stage for the specified filter

    Creates a graphLookup pipeline stage for the specified filter

    TExpression

    the expression type

    from

    the collection to query

    startWith

    the expression to start the graph lookup with

    connectFromField

    the from field

    connectToField

    the to field

    as

    name of field in output document

    options

    optional values for the graphLookup

    returns

    the $graphLookup pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 3.4 or greater

    See also

    $graphLookup

  19. def graphLookup[TExpression](from: String, startWith: TExpression, connectFromField: String, connectToField: String, as: String): Bson

    Creates a $graphLookup pipeline stage for the specified filter

    Creates a $graphLookup pipeline stage for the specified filter

    TExpression

    the expression type

    from

    the collection to query

    startWith

    the expression to start the graph lookup with

    connectFromField

    the from field

    connectToField

    the to field

    as

    name of field in output document

    returns

    the $graphLookup pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 3.4 or greater

    See also

    $graphLookup

  20. def group[TExpression](id: TExpression, fieldAccumulators: BsonField*): Bson

    Creates a $group pipeline stage for the specified filter

    Creates a $group pipeline stage for the specified filter

    TExpression

    the expression type

    id

    the id expression for the group

    fieldAccumulators

    zero or more field accumulator pairs

    returns

    the $group pipeline stage

    See also

    $group

    Expressions

  21. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  22. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  23. def limit(limit: Int): Bson

    Creates a $limit pipeline stage for the specified filter

    Creates a $limit pipeline stage for the specified filter

    limit

    the limit

    returns

    the $limit pipeline stage

    See also

    $limit

  24. def lookup[T](from: String, let: Seq[Variable[T]], pipeline: Seq[_ <: Bson], as: String): Bson

    Creates a $lookup pipeline stage, joining the current collection with the one specified in from using the given pipeline

    Creates a $lookup pipeline stage, joining the current collection with the one specified in from using the given pipeline

    from

    the name of the collection in the same database to perform the join with.

    let

    the variables to use in the pipeline field stages.

    pipeline

    the pipeline to run on the joined collection.

    as

    the name of the new array field to add to the input documents.

    returns

    the $lookup pipeline stage

    Since

    2.3

    Note

    Requires MongoDB 3.6 or greater

    See also

    $lookup

  25. def lookup(from: String, pipeline: Seq[_ <: Bson], as: String): Bson

    Creates a $lookup pipeline stage, joining the current collection with the one specified in from using the given pipeline

    Creates a $lookup pipeline stage, joining the current collection with the one specified in from using the given pipeline

    from

    the name of the collection in the same database to perform the join with.

    pipeline

    the pipeline to run on the joined collection.

    as

    the name of the new array field to add to the input documents.

    returns

    the $lookup pipeline stage:

    Since

    2.3

    Note

    Requires MongoDB 3.6 or greater

    See also

    $lookup

  26. def lookup(from: String, localField: String, foreignField: String, as: String): Bson

    Creates a $lookup pipeline stage for the specified filter

    Creates a $lookup pipeline stage for the specified filter

    from

    the name of the collection in the same database to perform the join with.

    localField

    specifies the field from the local collection to match values against.

    foreignField

    specifies the field in the from collection to match values against.

    as

    the name of the new array field to add to the input documents.

    returns

    the $lookup pipeline stage

    Since

    1.1

    Note

    Requires MongoDB 3.2 or greater

    See also

    $lookup

  27. def match(filter: Bson): Bson

    Creates a $match pipeline stage for the specified filter

    Creates a $match pipeline stage for the specified filter

    filter

    the filter to match

    returns

    the $match pipeline stage

    See also

    Filters

    $match

  28. def merge(namespace: MongoNamespace, mergeOptions: MergeOptions): Bson

    Creates a $merge pipeline stage that merges into the specified collection using the specified options.

    Creates a $merge pipeline stage that merges into the specified collection using the specified options.

    namespace

    the namespace to merge into

    mergeOptions

    the mergeOptions

    returns

    the $merge pipeline stage

    Since

    2.7

    See also

    http://docs.mongodb.org/manual/reference/operator/aggregation/merge/

  29. def merge(namespace: MongoNamespace): Bson

    Creates a $merge pipeline stage that merges into the specified collection using the specified options.

    Creates a $merge pipeline stage that merges into the specified collection using the specified options.

    namespace

    the namespace to merge into

    returns

    the $merge pipeline stage

    Since

    2.7

    See also

    http://docs.mongodb.org/manual/reference/operator/aggregation/merge/

  30. def merge(collectionName: String, mergeOptions: MergeOptions): Bson

    Creates a $merge pipeline stage that merges into the specified collection using the specified options.

    Creates a $merge pipeline stage that merges into the specified collection using the specified options.

    collectionName

    the name of the collection to merge into

    mergeOptions

    the mergeOptions

    returns

    the $merge pipeline stage

    Since

    2.7

    See also

    http://docs.mongodb.org/manual/reference/operator/aggregation/merge/

  31. def merge(collectionName: String): Bson

    Creates a $merge pipeline stage that merges into the specified collection using the specified options.

    Creates a $merge pipeline stage that merges into the specified collection using the specified options.

    collectionName

    the name of the collection to merge into

    returns

    the $merge pipeline stage

    Since

    2.7

    See also

    http://docs.mongodb.org/manual/reference/operator/aggregation/merge/

  32. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  33. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  34. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  35. def out(databaseName: String, collectionName: String): Bson

    Creates a $out pipeline stage that supports outputting to a different database.

    Creates a $out pipeline stage that supports outputting to a different database.

    databaseName

    the database name

    collectionName

    the collection name

    returns

    the $out pipeline stage

    See also

    $out

  36. def out(collectionName: String): Bson

    Creates a $out pipeline stage that writes to the collection with the specified name

    Creates a $out pipeline stage that writes to the collection with the specified name

    collectionName

    the collection name

    returns

    the $out pipeline stage

    See also

    $out

  37. def project(projection: Bson): Bson

    Creates a $project pipeline stage for the specified projection

    Creates a $project pipeline stage for the specified projection

    projection

    the projection

    returns

    the $project pipeline stage

    See also

    Projections

    $project

  38. def replaceRoot[TExpression](value: TExpression): Bson

    Creates a $replaceRoot pipeline stage

    Creates a $replaceRoot pipeline stage

    TExpression

    the new root type

    value

    the new root value

    returns

    the $replaceRoot pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 3.4 or greater

    See also

    $replaceRoot

  39. def replaceWith[TExpression](value: TExpression): Bson

    Creates a $replaceRoot pipeline stage

    Creates a $replaceRoot pipeline stage

    With $replaceWith, you can promote an embedded document to the top-level. You can also specify a new document as the replacement.

    The $replaceWith is an alias for replaceRoot.

    TExpression

    the new root type

    value

    the new root value

    returns

    the $replaceRoot pipeline stage

    Since

    2.7

    See also

    $replaceWith

  40. def sample(size: Int): Bson

    Creates a $sample pipeline stage with the specified sample size

    Creates a $sample pipeline stage with the specified sample size

    size

    the sample size

    returns

    the $sample pipeline stage

    Since

    1.1

    See also

    $sample

  41. def set(fields: Field[_]*): Bson

    Creates an $set pipeline stage

    Creates an $set pipeline stage

    fields

    the fields to add

    returns

    the $set pipeline stage

    Since

    4.3

    Note

    Requires MongoDB 4.2 or greater

    See also

    $set

  42. def setWindowFields[TExpression](partitionBy: TExpression, sortBy: Bson, output: WindowedComputation*): Bson

    Creates a $setWindowFields pipeline stage, which allows using window operators.

    Creates a $setWindowFields pipeline stage, which allows using window operators. This stage partitions the input documents similarly to the $group pipeline stage, optionally sorts them, computes fields in the documents by computing window functions over windows specified per function, and outputs the documents. The important difference from the $group pipeline stage is that documents belonging to the same partition or window are not folded into a single document.

    TExpression

    The partitionBy expression type.

    partitionBy

    Optional partitioning of data specified like id in Aggregates.group. If null, then all documents belong to the same partition.

    sortBy

    Fields to sort by. May be null. The syntax is identical to sort in Aggregates.sort (see Sorts). Sorting is required by certain functions and may be required by some windows (see Windows for more details). Sorting is used only for the purpose of computing window functions and does not guarantee ordering of the output documents.

    output

    A nonempty list of windowed computations.

    returns

    The $setWindowFields pipeline stage.

    Annotations
    @Beta()
    Since

    4.3

    Note

    Requires MongoDB 5.0 or greater.

    See also

    $setWindowFields

  43. def skip(skip: Int): Bson

    Creates a $skip pipeline stage

    Creates a $skip pipeline stage

    skip

    the number of documents to skip

    returns

    the $skip pipeline stage

    See also

    reference/operator/aggregation/skip/ $skip

  44. def sort(sort: Bson): Bson

    Creates a $sort pipeline stage for the specified sort specification

    Creates a $sort pipeline stage for the specified sort specification

    sort

    the sort specification

    See also

    Sorts

    $sort

  45. def sortByCount[TExpression](filter: TExpression): Bson

    Creates a $sortByCount pipeline stage for the specified filter

    Creates a $sortByCount pipeline stage for the specified filter

    TExpression

    the expression type

    filter

    the filter specification

    returns

    the $sortByCount pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 3.4 or greater

    See also

    Sorts

    $sortByCount

  46. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  47. def toString(): String
    Definition Classes
    AnyRef → Any
  48. def unionWith(collection: String, pipeline: Bson*): Bson

    Creates a $unionWith pipeline stage.

    Creates a $unionWith pipeline stage.

    collection

    the name of the collection in the same database to perform the union with.

    pipeline

    the pipeline to run on the union.

    returns

    the $unionWith pipeline stage

    See also

    http://docs.mongodb.org/manual/reference/operator/aggregation/unionWith/

  49. def unwind(fieldName: String, unwindOptions: UnwindOptions): Bson

    Creates a $unwind pipeline stage for the specified field name, which must be prefixed by a $ sign.

    Creates a $unwind pipeline stage for the specified field name, which must be prefixed by a $ sign.

    fieldName

    the field name, prefixed by a $ sign

    returns

    the $unwind pipeline stage

    Since

    1.1

    See also

    $unwind

  50. def unwind(fieldName: String): Bson

    Creates a $unwind pipeline stage for the specified field name, which must be prefixed by a $ sign.

    Creates a $unwind pipeline stage for the specified field name, which must be prefixed by a $ sign.

    fieldName

    the field name, prefixed by a $ sign

    returns

    the $unwind pipeline stage

    See also

    $unwind

  51. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  52. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  53. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped