at

infix inline fun <T> Bson.at(path: BsonPath): T(source)

Finds the first value that matches path in a given BSON document.

Example

val document: Bson = …

val bar: String = document at BsonPath["foo"]["bar"]

will return the value of the field foo.bar.

Depending on your situation, you can also use the equivalent function selectFirst:

val document: Bson = …

document.selectFirst<String>(BsonPath["foo"]["bar"])

See also

Learn more about BSON paths.

Select multiple values with a BSON path.

Throws

If no element is found matching the path.