Closed
Description
Tjeu opened DATAMONGO-2138 and commented
MongoTemplate already has many Kotlin extensions, and I'm suggesting to add extensions for "type-safe queries". This will prevent typos in field names, and improve the readability of a query.
The KMongo library uses Kotlin's Property References and infix functions for a type safe query syntax:
data class Jedi(val name: String)
val yoda = col.findOne(Jedi::name eq "Yoda")
https://github.com/Litote/kmongo/blob/master/kmongo-kdoc/docs/typed-queries.md
Spring Data MonoDB could provide a similar syntax:
val classic = Criteria("price").gt(1100)
.and("available").isEqualTo(true)
val typed = typedCriteria {
Book::price gt 1100
Book::available isEqualTo true
}
assertEquals(classic, typed)
https://gist.github.com/TjeuKayim/91f52ae21bd5c33b99de028383d5ed89
I like to help coding this feature. It would be my first contribution to Spring
Reference URL: #622
Issue Links:
- DATAMONGO-2162 Add support for extended AND/OR query criteria using type-safe Kotlin queries
("is depended on by") - DATAMONGO-2163 Type-safe Kotlin update extension
("is depended on by") - DATAREST-1433 UnsatisfiedDependencyException with custom ID mapping in Kotlin
Referenced from: pull request #622
0 votes, 5 watchers