Skip to content

ReadPreferenceOption

Specifies the read preference for an operation.

To learn more about read preferences, see ReadPreference. To apply this option, see WithReadPreference.

Constructors

ReadPreferenceOption

constructor(concern: ReadPreference, context: BsonContext)

Properties

concern

context

@LowLevelApi



open override val context: BsonContext

The context used to generate this expression.

name

open override val name: String

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

Options always have the form:

find(
    {
        "limit": 10,
        "sort": { }
    },
    { }
)

In this example, the LimitOption has the name "limit" and the SortOption has the name "sort".

Implementation notes

This value should be immutable.

Functions

freeze

@LowLevelApi



open override fun freeze()

Makes this node immutable.

read

@LowLevelApi



override fun read(): BsonValueReader

Reads the value of this option.

Performance

Note that this method requires to write this option into a temporary BSON value.

simplify

@LowLevelApi



open override fun simplify(): AbstractBsonNode?

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

toBson

@LowLevelApi



open fun toBson(): Bson

Writes the result of simplifying to a new BSON document.

toString

override fun toString(): String

JSON representation of this expression.

fun toString(simplified: Boolean): String

JSON representation of this expression.

writeTo

@LowLevelApi



override fun writeTo(writer: BsonFieldWriter)

Writes the result of simplifying this expression into writer.