MongoDB request DSL • opensavvy.ktmongo.dsl.path • toBsonPath
toBsonPath¶
fun Path.toBsonPath(): ERROR CLASS: Symbol not found for BsonPath
Converts this MongoDB Path to a BsonPath.
BsonPath is an implementation of RFC9535 JSONPath. See its documentation for more information.
fun Field<*, *>.toBsonPath(): ERROR CLASS: Symbol not found for BsonPath
Converts this MongoDB Field to a BsonPath.
BsonPath is an implementation of RFC9535 JSONPath. See its documentation for more information.
BsonPath can be useful to access elements from an arbitrary BSON document, for example, after a projection.
Example¶
data class User(
val _id: ObjectId,
val profile: Profile,
)
data class Profile(
val name: String,
)
val fieldName = (User::profile / Profile::name).toBsonPath()
val bson: Bson = …
val name = bson at fieldName
See also¶
-
selectSelect multiple values. -
selectFirstSelect the first value. -
atSelect the first value, as an infix operator.