Kotlin BSON • Multiplatform abstraction for different BSON implementations • opensavvy.ktmongo.bson • BsonPath • any
any¶
open fun any(vararg selectors: BsonPath.Selector): BsonPath
Allows specifying multiple selectors.
All elements that match a selector are returned, in the order of the selectors. For example, the path $[0, 3] returns the elements at index 0 and at index 3.
The same element may be returned multiple times if it matches multiple selectors.
The Selector type is obtained by the top-level functions on BsonPath.Root. Non-top-level paths are not allowed by the JSONPath specification.
Examples¶
-
BsonPath.any(BsonPath[0], BsonPath[3])returns["a", "d"] -
BsonPath.any(BsonPath.sliced(0, 2), BsonPath[5])returns["a", "b", "f"] -
BsonPath.any(BsonPath[0], BsonPath[0])returns["a", "a"]