projection

fun <T : Any> FindIterable<T>.projection(projection: String): FindIterable<T>

Sets a document describing the fields to return for all matching documents.

Return

this

Parameters

projection

the project document


fun <T : Any> FindIterable<T>.projection(vararg projections: KProperty<*>): FindIterable<T>

Sets a document describing the fields to return for all matching documents.

Return

this

Parameters

projections

the properties of the returned fields


inline fun <T : Any, F> MongoCollection<T>.projection(property: KProperty<F>, query: Bson = EMPTY_BSON, options: (FindIterable<SingleProjection<F>>) -> FindIterable<SingleProjection<F>> = { it }): MongoIterable<F?>

Returns the specified field for all matching documents.

Return

a property value iterable (null values if the field is missing or null)

Parameters

property

the property to return

query

the optional find query

options

the optional FindIterable modifiers


inline fun <T : Any, F1, F2> MongoCollection<T>.projection(property1: KProperty<F1>, property2: KProperty<F2>, query: Bson = EMPTY_BSON, options: (FindIterable<PairProjection<F1, F2>>) -> FindIterable<PairProjection<F1, F2>> = { it }): MongoIterable<Pair<F1?, F2?>>

Returns the specified two fields for all matching documents.

Return

a pair of property values iterable

Parameters

property1

the first property to return

property2

the second property to return

query

the optional find query

options

the optional FindIterable modifiers


inline fun <T : Any, F1, F2, F3> MongoCollection<T>.projection(property1: KProperty<F1>, property2: KProperty<F2>, property3: KProperty<F3>, query: Bson = EMPTY_BSON, options: (FindIterable<TripleProjection<F1, F2, F3>>) -> FindIterable<TripleProjection<F1, F2, F3>> = { it }): MongoIterable<Triple<F1?, F2?, F3?>>

Returns the specified three fields for all matching documents.

Return

a triple of property values iterable

Parameters

property1

the first property to return

property2

the second property to return

property3

the third property to return

query

the optional find query

options

the optional FindIterable modifiers


inline fun <T : Any, F> MongoCollection<T>.projection(clientSession: ClientSession, property: KProperty<F>, query: Bson = EMPTY_BSON, options: (FindIterable<SingleProjection<F>>) -> FindIterable<SingleProjection<F>> = { it }): MongoIterable<F?>

Returns the specified field for all matching documents.

Return

a property value iterable (null values if the field is missing or null)

Parameters

clientSession

the client session with which to associate this operation

property

the property to return

query

the optional find query

options

the optional FindIterable modifiers


inline fun <T : Any, F1, F2> MongoCollection<T>.projection(clientSession: ClientSession, property1: KProperty<F1>, property2: KProperty<F2>, query: Bson = EMPTY_BSON, options: (FindIterable<PairProjection<F1, F2>>) -> FindIterable<PairProjection<F1, F2>> = { it }): MongoIterable<Pair<F1?, F2?>>

Returns the specified two fields for all matching documents.

Return

a pair of property values iterable

Parameters

clientSession

the client session with which to associate this operation

property1

the first property to return

property2

the second property to return

query

the optional find query

options

the optional FindIterable modifiers


inline fun <T : Any, F1, F2, F3> MongoCollection<T>.projection(clientSession: ClientSession, property1: KProperty<F1>, property2: KProperty<F2>, property3: KProperty<F3>, query: Bson = EMPTY_BSON, options: (FindIterable<TripleProjection<F1, F2, F3>>) -> FindIterable<TripleProjection<F1, F2, F3>> = { it }): MongoIterable<Triple<F1?, F2?, F3?>>

Returns the specified three fields for all matching documents.

Return

a triple of property values iterable

Parameters

clientSession

the client session with which to associate this operation

property1

the first property to return

property2

the second property to return

property3

the third property to return

query

the optional find query

options

the optional FindIterable modifiers