Skip to content

MongoDB request DSLopensavvy.ktmongo.dsl.optionsSortOptionDsl

SortOptionDsl

DSL to describe a sort order.

This DSL declares the methods ascending and descending which describe in which order elements are sorted.

For example,

ascending(User::name)
descending(User::age)

will sort users in alphabetical order of their name, and when users have the same name, will sort them in decreasing order of their age.

See WithSort.sort.

Properties

context

abstract val context: 

The context used to generate this expression.

field

Converts a Kotlin property into a Field.

Functions

accept

abstract override fun accept(node: BsonNode)

Adds a new node as a child of this one.

acceptAll

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

Adds any number of nodes into this one.

ascending

open fun ascending(field: KProperty1<Document, *>)

If two documents have a different value of field, the one with lesser value will be returned first.

abstract fun ascending(field: Field<Document, *>)

If two documents have a different value of field, the one with lesser value will be returned first.

descending

open fun descending(field: KProperty1<Document, *>)

If two documents have a different value of field, the one with greater value will be returned first.

abstract fun descending(field: Field<Document, *>)

If two documents have a different value of field, the one with greater value will be returned first.

div

open operator fun <Root, Parent, Child> KProperty1<Root, Parent>.div(child: KProperty1<Parent & Any, Child>): Field<Root, Child>

Refers to child as a nested field of the current field.

freeze

abstract override fun freeze()

Makes this expression immutable.

get

open operator fun <Root, Type> KProperty1<Root, Collection<Type>>.get(index: Int): Field<Root, Type>

Refers to a specific item in an array, by its index.

open operator fun <Root, Type> KProperty1<Root, Map<String, Type>>.get(index: String): Field<Root, Type>

Refers to a specific item in a map, by its name.

simplify

abstract fun simplify(): BsonNode?

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

toBson

open fun toBson(): 

Writes the result of simplifying to a new Bson.

toString

abstract override fun toString(): String

JSON representation of this expression.

writeTo

abstract fun writeTo(writer: )

Writes the result of simplifying this expression into writer.