Skip to content

MongoDB request DSLopensavvy.ktmongo.dsl.path

Package-level declarations

Utilities for referencing variables and classes.

User::_id                          // _id
User::profile / Profile::name      // profile.name
User::friends[1] / Friend::name    // friends.$1.name

This package contains a low-level type-unsafe implementation of arbitrary document paths, and a high-level type-safe wrapper that provides the above utility functions.

Note that some functions are only provided when the FieldDsl is into scope (which should be done automatically by most operators). This means that you should rarely need to import anything for these functions to be available.

Operators

Types

Field

interface Field<in Root, out Type>

High-level, typesafe pointer to a specific field in a document.

FieldDsl

interface FieldDsl

DSL to refer to fields, usually automatically added into scope by operators.

Path

data class Path(val segment: PathSegment, val parent: Path?)

Low-level, type-unsafe pointer to a specific field in a document.

PathSegment

sealed class PathSegment

Single segment in a Path.

Functions

div

operator fun Path.div(path: Path): Path

Returns a new Path instance that is the concatenation of the current path and a child path.

operator fun Path.div(segment: PathSegment): Path

Returns a new Path instance that is the concatenation of the current path and a segment.

get

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

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

operator fun <Root, Type> Field<Root, Map<String, Type>>.get(key: String): Field<Root, Type>

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

Path

fun Path(root: String): Path

Creates a root path from the provided root field name.