Package-level declarations
Syntax to refer to specific fields in MongoDB documents.
When creating a query, we need to refer to specific fields in a MongoDB document, which may be in a nested document or in an array. Traditionally, this is done with the string representation of the path, but that leads to brittle code that is hard to navigate and refactor. Instead, KtMongo provides a DSL to refer to fields with type-safety:
User::_id // _id
User::profile / Profile::name // profile.name
User::friends[1] / Friend::name // friends.1.nameThe operators are implemented in the interface FieldDsl which is already brought into scope by all KtMongo methods, and return instances of Field, the type-safe representation of a MongoDB path.
Operators
Types
Operators to construct MongoDB field references from Kotlin code.
Low-level, type-unsafe pointer to a specific field in a document.
Single segment in a Path.
Allows configuring how the DSL generates MongoDB paths from KProperty1 instances.
Functions
Returns a new Path instance that is the concatenation of the current path and a child path.
Creates an instance of FieldDsl.
Finds the first value that matches field in a given BSON document.