Skip to content

AbstractCompoundBsonNode

Abstract utility class to help implement CompoundBsonNode.

Learn more by reading BsonNode, AbstractBsonNode and CompoundBsonNode.

Constructors

AbstractCompoundBsonNode

constructor(context: BsonContext)

Types

Companion

object Companion

Properties

context

@LowLevelApi



open override val context: BsonContext

The context used to generate this expression.

Functions

accept

@LowLevelApi



@DangerousMongoApi



open override fun accept(node: BsonNode)

Adds a new node as a child of this one.

Since BsonNode subtypes may generate arbitrary BSON, it is possible to use this method to inject arbitrary BSON (escaped or not) into any KtMongo DSL. Incorrect BsonNode implementations can create memory leaks, performance issues, data corruption or data leaks.

We recommend against calling this function directly. Instead, you should find other functions declared on this object (possibly as extensions) that perform the operation you want in safe manner.

acceptAll

@LowLevelApi



@DangerousMongoApi



fun <N : Node> CompoundNode<N>.acceptAll(nodes: Iterable<N>)

Adds any number of nodes into this one.

To learn more about the behavior of this function and the security implications, see accept.

freeze

@LowLevelApi



abstract fun freeze()

Makes this node immutable.

After this method has been called, the expression can never be modified again. This ensures that nodes cannot change after they have been used within other nodes.

To learn more about this process, see Node.

simplify

@LowLevelApi



override fun simplify(): AbstractBsonNode?

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

Returns null when the current expression was simplified into a no-op (= it does nothing).

toBson

@LowLevelApi



open fun toBson(): Bson

Writes the result of simplifying to a new BSON document.

toString

fun toString(simplified: Boolean): String

JSON representation of this expression.

By default, simplifications are enabled. Set simplified to false to disable simplifications.

override fun toString(): String

JSON representation of this expression.

writeTo

@LowLevelApi



override fun writeTo(writer: BsonFieldWriter)

Writes the result of simplifying this expression into writer.