Value

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

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

Builder for aggregation values.

Inheritors

Properties

Link copied to clipboard
abstract val context: <Error class: unknown class>

The context used to generate this value.

Functions

Link copied to clipboard
abstract override fun freeze()

Makes this value immutable.

Link copied to clipboard
abstract fun simplify(): Value<Root, Type>

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

Link copied to clipboard
abstract override fun toString(): String

JSON representation of this expression.

Link copied to clipboard
abstract fun writeTo(writer: <Error class: unknown class>)

Writes the result of simplifying this value into writer.