object Aggregates
- Alphabetic
- By Inheritance
- Aggregates
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def addFields(fields: Field[_]*): Bson
Creates an
$addFields
pipeline stageCreates 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
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def bucket[TExpression, TBoundary](groupBy: TExpression, options: BucketOptions, boundaries: TBoundary*): Bson
Creates a
$bucket
pipeline stageCreates 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
- 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
- def bucketAuto[TExpression, TBoundary](groupBy: TExpression, buckets: Int, options: BucketAutoOptions): Bson
Creates a
$bucketAuto
pipeline stageCreates 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
- def bucketAuto[TExpression, TBoundary](groupBy: TExpression, buckets: Int): Bson
Creates a
$bucketAuto
pipeline stageCreates 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
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def count(field: String): Bson
Creates a
$count
pipeline stage using the named field to store the resultCreates 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
- def count(): Bson
Creates a
$count
pipeline stage using the field name "count" to store the resultCreates 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
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def facet(facets: Facet*): Bson
Creates a
$facet
pipeline stageCreates 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
- def filter(filter: Bson): Bson
Creates a
$match
pipeline stage for the specified filterCreates a
$match
pipeline stage for the specified filterA friendly alias for the
match
method.- filter
the filter to match against
- returns
the
$match
pipeline stage
- See also
Filters
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- 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
- def graphLookup[TExpression](from: String, startWith: TExpression, connectFromField: String, connectToField: String, as: String): Bson
Creates a
$graphLookup
pipeline stage for the specified filterCreates 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
- def group[TExpression](id: TExpression, fieldAccumulators: BsonField*): Bson
Creates a
$group
pipeline stage for the specified filterCreates 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
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def limit(limit: Int): Bson
Creates a
$limit
pipeline stage for the specified filterCreates a
$limit
pipeline stage for the specified filter- limit
the limit
- returns
the
$limit
pipeline stage
- See also
- 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 pipelineCreates 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
- 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 pipelineCreates 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
- def lookup(from: String, localField: String, foreignField: String, as: String): Bson
Creates a
$lookup
pipeline stage for the specified filterCreates 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
- def match(filter: Bson): Bson
Creates a
$match
pipeline stage for the specified filterCreates a
$match
pipeline stage for the specified filter- filter
the filter to match
- returns
the
$match
pipeline stage
- See also
Filters
- 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
- 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
- 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
- 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
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- 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
- def out(collectionName: String): Bson
Creates a
$out
pipeline stage that writes to the collection with the specified nameCreates a
$out
pipeline stage that writes to the collection with the specified name- collectionName
the collection name
- returns
the
$out
pipeline stage
- See also
- def project(projection: Bson): Bson
Creates a
$project
pipeline stage for the specified projectionCreates a
$project
pipeline stage for the specified projection- projection
the projection
- returns
the
$project
pipeline stage
- See also
Projections
- def replaceRoot[TExpression](value: TExpression): Bson
Creates a
$replaceRoot
pipeline stageCreates 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
- def replaceWith[TExpression](value: TExpression): Bson
Creates a
$replaceRoot
pipeline stageCreates a
$replaceRoot
pipeline stageWith
$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
- def sample(size: Int): Bson
Creates a
$sample
pipeline stage with the specified sample sizeCreates a
$sample
pipeline stage with the specified sample size- size
the sample size
- returns
the
$sample
pipeline stage
- Since
1.1
- See also
- 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
- 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. Ifnull
, then all documents belong to the same partition.- sortBy
Fields to sort by. May be
null
. The syntax is identical tosort
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
- def skip(skip: Int): Bson
Creates a
$skip
pipeline stageCreates a
$skip
pipeline stage- skip
the number of documents to skip
- returns
the
$skip
pipeline stage
- def sort(sort: Bson): Bson
Creates a
$sort
pipeline stage for the specified sort specificationCreates a
$sort
pipeline stage for the specified sort specification- sort
the sort specification
- See also
Sorts
- def sortByCount[TExpression](filter: TExpression): Bson
Creates a
$sortByCount
pipeline stage for the specified filterCreates 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
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- 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
- 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
- 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
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
This is the documentation for the MongoDB Scala driver.
Driver structure
The mongodb scala driver.
To get started you need a MongoClient instance, either from a connection string or via a org.mongodb.scala.MongoClientSettings.
Notable packages include: