Kotlin BSON • Multiplatform abstraction for different BSON implementations • opensavvy.ktmongo.bson • selectFirst
selectFirst¶
inline fun <T> Bson.selectFirst(path: BsonPath): T
Finds the first value that matches path in a given BSON document.
Example¶
will return the value of the field foo.bar.
Alternatives¶
Depending on your situation, you can also use the equivalent function at:
See also¶
Throws¶
NoSuchElementException-
If no element is found matching the path.
inline fun <T> Bson.selectFirst(@Language
(value = "JSONPath") path: String): T
Finds the first value that matches path in a given BSON document.
To learn more about the syntax, see BsonPath.
Example¶
will return the value of the field foo.bar.