MongoDB request DSL • opensavvy.ktmongo.dsl.aggregation • AggregationPipeline
AggregationPipeline¶
interface AggregationPipeline<Document : Any> : Pipeline<Document> , HasCount<Document> , HasGroup<Document> , HasLimit<Document> , HasMatch<Document> , HasProject<Document> , HasSample<Document> , HasSet<Document> , HasSkip<Document> , HasSort<Document> , HasUnionWith<Document> , HasUnionWithCompatibility<Document> , HasUnset<Document>
An aggregation pipeline.
Aggregation pipelines read data from one or more collections and transform it in a manner of ways. Finally, the data can be sent to the server, or written to another collection.
Example¶
invoices.aggregate()
.match { Invoice::isDraft eq false }
.set {
Invoice::anomaly set (of(Invoice::modificationDate) lt of(Invoice::creationDate))
}
.sort { ascending(Invoice::creationDate) }
.toList()
External resources¶
Properties¶
context
¶
abstract val context:
The context used to generate this pipeline.
Functions¶
countTo
¶
Counts how many elements exist in the pipeline and outputs a single document containing a single field
containing the count.
Counts how many elements exist in the pipeline and outputs a single document containing a single field
containing the count.
embedInUnionWith
¶
abstract fun embedInUnionWith(writer: )
Writes this pipeline into a $unionWith
stage.
group
¶
Combines multiple documents into a single document.
limit
¶
Limits the number of elements passed to the next stage to amount
.
Limits the number of elements passed to the next stage to amount
.
match
¶
Filters documents based on a specified filter
.
project
¶
Specifies a list of fields which should be kept in the document.
reinterpret
¶
abstract fun <New : Any> reinterpret(): Pipeline<New>
Changes the type of the returned document, with no type-safety.
sample
¶
Randomly selects size
documents.
set
¶
Adds new fields to documents, or overwrites existing fields.
skip
¶
Skips over the specified amount
of documents that pass into the stage, and passes the remaining documents to the next stage.
Skips over the specified amount
of documents that pass into the stage, and passes the remaining documents to the next stage.
sort
¶
Specifies in which order elements should be sorted.
toString
¶
JSON representation of this pipeline.
unionWith
¶
open fun unionWith(other: HasUnionWithCompatibility<Document>): Pipeline<Document>
Combines two aggregations into a single result set.
unset
¶
Removes fields from documents.
withStage
¶
Creates a new pipeline that expands on the current one by adding stage
.
writeTo
¶
abstract fun writeTo(writer: )
Writes the entire pipeline into writer
.