Projection

Companion
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def combinedWith(anotherProjection: Projection): Projection

Merges 2 sequences of projection operations together. If there are duplicate keys, the last one takes precedence.

Merges 2 sequences of projection operations together. If there are duplicate keys, the last one takes precedence.

Value Params
anotherProjection

the projection to be merged with

Returns

the projection

def computed[T](fieldName: String, expression: T): Projection

Creates a projection of a field whose value is computed from the given expression. Projection with an expression is only supported using the $project aggregation pipeline stage.

Creates a projection of a field whose value is computed from the given expression. Projection with an expression is only supported using the $project aggregation pipeline stage.

Value Params
expression

the expression

fieldName

the field name

Returns

the projection

def elemMatch(fieldName: String): Projection

Creates a projection that includes for the given field only the first element of an array that matches the query filter. This is referred to as the positional $ operator.

Creates a projection that includes for the given field only the first element of an array that matches the query filter. This is referred to as the positional $ operator.

Value Params
fieldName

the field name whose value is the array

Returns

the projection

def elemMatch(fieldName: String, filter: Filter): Projection

Creates a projection that includes for the given field only the first element of the array value of that field that matches the given query filter.

Creates a projection that includes for the given field only the first element of the array value of that field that matches the given query filter.

Value Params
fieldName

the field name

filter

the filter to apply

Returns

the projection

def exclude(fieldName: String): Projection

Creates a projection that excludes all of the given fields.

Creates a projection that excludes all of the given fields.

Value Params
fieldName

the field name

Returns

the projection

def exclude(fieldNames: Seq[String]): Projection

Creates a projection that excludes all of the given fields.

Creates a projection that excludes all of the given fields.

Value Params
fieldNames

the field names

Returns

the projection

Creates a projection that excludes the _id field. This suppresses the automatic inclusion of _id that is the default, even when other fields are explicitly included.

Creates a projection that excludes the _id field. This suppresses the automatic inclusion of _id that is the default, even when other fields are explicitly included.

Returns

the projection

def include(fieldName: String): Projection

Creates a projection that includes all of the given fields.

Creates a projection that includes all of the given fields.

Value Params
fieldName

the field name

Returns

the projection

def include(fieldNames: Seq[String]): Projection

Creates a projection that includes all of the given fields.

Creates a projection that includes all of the given fields.

Value Params
fieldNames

the field names

Returns

the projection

def meta(fieldName: String, metaFieldName: String): Projection

Creates a $meta projection to the given field name for the given meta field name.

Creates a $meta projection to the given field name for the given meta field name.

Value Params
fieldName

the field name

metaFieldName

the meta field name

Returns

the projection

Since

4.1

def metaTextScore(fieldName: String): Projection

Creates a projection to the given field name of the textScore, for use with text queries.

Creates a projection to the given field name of the textScore, for use with text queries.

Value Params
fieldName

the field name

Returns

the projection

def slice(fieldName: String, limit: Int): Projection

Creates a projection to the given field name of a slice of the array value of that field.

Creates a projection to the given field name of a slice of the array value of that field.

Value Params
fieldName

the field name

limit

the number of elements to project.

Returns

the projection

def slice(fieldName: String, skip: Int, limit: Int): Projection

Creates a projection to the given field name of a slice of the array value of that field.

Creates a projection to the given field name of a slice of the array value of that field.

Value Params
fieldName

the field name

limit

the number of elements to project

skip

the number of elements to skip before applying the limit

Returns

the projection