Skip to content

MongoDB request DSLopensavvy.ktmongo.dsl.aggregationValue

Value

interface Value<in Root : Any, out Type> : Node

An intermediary value in an aggregation expression.

Each implementation of this interface is a logical BSON node in our own intermediate representation. Each node knows how to writeTo itself into a BSON document.

Instances of this interface are obtained by the end-user through the AggregationOperators builder. Functions from KtMongo which expect aggregation values provide an instance of AggregationOperators into scope automatically. For example, see FilterQuery.expr.

Difference with Expression

This interface and its hierarchy mimic BsonNode. The main difference is the expected context: BsonNode represents an operator, which is stored as a BSON document and doesn't participate in any type hierarchy. Instead, Value is stored as a BSON value and its return type can be further embedded into more values.

Security

Implementing this interface allows injecting arbitrary BSON into a request. Be very careful not to make injections possible.

Implementation notes

Prefer implementing AbstractValue instead of implementing this interface directly.

Debugging notes

Use toString to view the JSON representation of this expression.

See also

Inheritors

Properties

context

abstract val context: 

The context used to generate this value.

Functions

freeze

abstract override fun freeze()

Makes this value immutable.

simplify

abstract fun simplify(): Value<Root, Type>

Returns a simplified (but equivalent) value to the current value.

toString

abstract override fun toString(): String

JSON representation of this expression.

writeTo

abstract fun writeTo(writer: )

Writes the result of simplifying this value into writer.