selectFirst
Finds the first value that matches path in a given BSON document.
Example
val document: Bson = …
document.selectFirst<String>(BsonPath["foo"]["bar"])Content copied to clipboard
will return the value of the field foo.bar.
Alternatives
Depending on your situation, you can also use the equivalent function at:
val document: Bson = …
val bar: String = document at BsonPath["foo"]["bar"]Content copied to clipboard
See also
Throws
If no element is found matching the path.