MongoDB request DSL¶
Pure Kotlin DSL targeting all MongoDB operators.
Pure Kotlin implementation of MongoDB operators, based on dev.opensavvy.ktmongo:bson
. All platforms supported by :bson
are also supported by this module.
It is not expected that end-users will have a direct dependency on this module. Instead, we expect end-users to have a dependency on one of the "driver" modules: driver-sync
or driver-coroutines
.
Introduction¶
No matter whether you use the synchronous or the coroutines drivers, you must construct BSON instances to communicate with MongoDB. While the :bson
module allows writing arbitrary BSON, it is rather low-level and requires to take care of escaping as well as remembering the syntax for each operator. This module provides a Kotlin function for each MongoDB operator:
To learn more about the Class::field
syntax, and how to refer to fields in general, see Field
.
Operator DSLs¶
Operators are organized by the context in which they are available in. For example, the $eq
operator cannot be used in an update
's modification field, but it can be used in an update
's filter field.
Instances of these classes are usually provided by the driver as part of its functions.
-
opensavvy.ktmongo.dsl.query.UpdateOperators
-
opensavvy.ktmongo.dsl.query.UpsertOperators
To create a custom operator (for example because it isn't part of the library yet), see opensavvy.ktmongo.dsl.query.common.AbstractExpression.
Aggregation DSLs¶
KtMongo has support for aggregation pipelines through dedicated DSLs.
-
opensavvy.ktmongo.dsl.aggregation.ValueDsl
Packages¶
opensavvy.ktmongo.dsl
¶
Annotations and other global concepts.
opensavvy.ktmongo.dsl.aggregation
¶
Aggregation pipelines are powerful ways to query and update MongoDB documents. Compared to regular queries, aggregation pipelines can perform more complex operations, can compare fields from the same document together, or combine data from other sources.
opensavvy.ktmongo.dsl.aggregation.accumulators
¶
opensavvy.ktmongo.dsl.aggregation.operators
¶
opensavvy.ktmongo.dsl.aggregation.stages
¶
opensavvy.ktmongo.dsl.command
¶
opensavvy.ktmongo.dsl.options
¶
opensavvy.ktmongo.dsl.path
¶
Utilities for referencing variables and classes.
opensavvy.ktmongo.dsl.query
¶
Operators, classified by the context in which they are available in.
opensavvy.ktmongo.dsl.tree
¶
Helpers to represent trees of data built bottom-up. Nodes become immutable when they become branches of another tree, and offer utilities for debugging (e.g. JSON representation in their toString
implementation).