Option

interface Option : BsonNode(source)

Additional parameters that are passed to MongoDB operations.

Options are usually configured with the options = {} optional parameter in a command. For example, if we want to know how many notifications a user has, but can only display "99" because of UI size constraints, we can use the following command:

notifications.count(
options = {
limit(99)
}
) {
Notification::ownedBy eq currentUser
}

If the same option is specified multiple times, only the very last one applies:

notifications.count {
options {
limit(99)
limit(10)
}
}

will only count at most 10 elements.

Accessing the current value of an option

See Options.allOptions and option.

Implementing this interface

Implementations of this interface must be careful to respect the contract of BsonNode, in particular about the toString representation.

Option implementations must be immutable. If the user wants to change an option, they can specify it a second time (which will override the previous one).

Inheritors

Properties

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

The context used to generate this expression.

Link copied to clipboard
abstract val name: String

The name of this option, as it appears in the BSON representation.

Functions

Link copied to clipboard
abstract override fun freeze()

Makes this expression immutable.

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

Reads the value of this option.

Link copied to clipboard
abstract fun simplify(): BsonNode?

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

Link copied to clipboard
open fun toBson(): <Error class: unknown class>

Writes the result of simplifying to a new Bson.

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 expression into writer.