lookup

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.

Return

the $lookup pipeline stage @mongodb.driver.manual reference/operator/aggregation/lookup/ $lookup @mongodb.server.release 3.6

Parameters

from

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

localField

the data class field from the local collection to match values against.

foreignField

the data class field in the from collection to match values against.

pipeline

the pipeline to run on the joined collection.

as

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