Aggregates

object Aggregates

Aggregates extension methods to improve Kotlin interop

Since

5.3

Functions

Link copied to clipboard
fun <T> count(property: KProperty<T>): Bson

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

Link copied to clipboard
fun <T> densify(property: KProperty<T>, range: DensifyRange): Bson

Creates a $densify pipeline stage, which adds documents to a sequence of documents where certain values in the field are missing.

fun <T> densify(property: KProperty<T>, range: DensifyRange, options: DensifyOptions): Bson

Creates a {@code $densify} pipeline stage, which adds documents to a sequence of documents where certain values in the {@code field} are missing.

Link copied to clipboard
fun <TExpression, FROM : Any> graphLookup(from: MongoCollection<FROM>, startWith: TExpression, connectFromField: KProperty1<FROM, Any?>, connectToField: KProperty1<FROM, Any?>, fieldAs: String, options: GraphLookupOptions = GraphLookupOptions()): Bson
fun <TExpression, FROM : Any> graphLookup(from: MongoCollection<FROM>, startWith: TExpression, connectFromField: KProperty1<FROM, Any?>, connectToField: KProperty1<FROM, Any?>, fieldAs: String, options: GraphLookupOptions = GraphLookupOptions()): Bson

Creates a graphLookup pipeline stage for the specified filter

Link copied to clipboard
fun <FROM : Any> lookup(from: MongoCollection<FROM>, localField: KProperty1<out Any, Any?>, foreignField: KProperty1<FROM, Any?>, newAs: String): Bson
fun <FROM : Any> lookup(from: MongoCollection<FROM>, localField: KProperty1<out Any, Any?>, foreignField: KProperty1<FROM, Any?>, newAs: String): Bson

Creates a $lookup pipeline stage, joining the current collection with the one specified in from using the given pipeline. If the first stage in the pipeline is a {@link Aggregates#documents(List) $documents} stage, then the {@code from} collection is ignored.

Link copied to clipboard
fun merge(collection: MongoCollection<*>, options: MergeOptions = MergeOptions()): Bson
fun merge(collection: MongoCollection<*>, options: MergeOptions = MergeOptions()): Bson

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

Link copied to clipboard
fun out(collection: MongoCollection<*>): Bson
fun out(collection: MongoCollection<*>): Bson

Creates a $out pipeline stage that writes into the specified collection

Link copied to clipboard
fun unionWith(collection: MongoCollection<*>, pipeline: List<Bson>): Bson
fun unionWith(collection: MongoCollection<*>, pipeline: List<Bson>): Bson

Creates a $unionWith pipeline stage.

Link copied to clipboard
fun <T> unwind(property: KProperty<Iterable<T>?>, unwindOptions: UnwindOptions = UnwindOptions()): Bson

Creates a $unwind pipeline stage for the specified field name, which must be prefixed by a {@code '$'} sign.