MongoPath
io.github.mbannour.fields.MongoPath
object MongoPath
Macro-powered extractor for case-class field paths that map to MongoDB document keys.
Core ideas:
- Accepts a selector lambda like
_.address.zipCodeand returns a dot-separated path (e.g. "address.zip"). - Honors
@BsonPropertyon constructor parameters and uses the overridden name when present. - Supports a transparent hop over
Optionvia the.?syntax imported fromMongoPath.syntax.
Usage: import io.github.mbannour.fields.MongoPath import io.github.mbannour.fields.MongoPath.syntax.?
case class Address(street: String, @BsonProperty("zip") zipCode: Int) case class User(address: Option[Address])
MongoPath.ofUser // "address" MongoPath.ofUser // "address.zip"
Notes:
- The
.?method is never executed at runtime; it only helps the lambda typecheck and be recognized by the macro. - If the macro cannot detect a valid case-class field selection chain, it will abort compilation with an error.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
MongoPath.type
Members list
In this article