toBsonPath
Converts this MongoDB Path to a BsonPath.
BsonPath is an implementation of RFC9535 JSONPath. See its documentation for more information.
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 fieldNameContent copied to clipboard
See also
Select multiple values.
Select the first value.
Select the first value, as an infix operator.