MIGHT NOT SUPPORT JAVA 1.7!
Benefits :
How to ?
compile 'org.litote.kmongo:kmongo:3.8.2'
to build.gradle
class SomeMongoAccessor(mongoDatabase: MongoDatabase)
: SomeAccessor {
private val codecRegistry = ClassMappingType
.codecRegistry(MongoClient.getDefaultCodecRegistry())
private val collection = mongoDatabase
.getCollection("your.collection", YourDataClass::class.java)
.withCodecRegistry(codecRegistry)
}
3. Done! you can code such ascollection.insertOne(YourDataClass(_id = id))
or,
return collection
.find(filters)
.sort(descending(AccomPropertyMergeTaskHistory::_id))
.limit(limit+1)
.toMutableList()
or
collection.updateOne(
and(
AccomPropertyMergeTask::_id eq id,
or(
AccomPropertyMergeTask::resolution eq Free,
AccomPropertyMergeTask::resolution eq Locked,
AccomPropertyMergeTask::resolution eq Archive
)
),
set(
AccomPropertyMergeTask::handledTime setTo currentTime,
AccomPropertyMergeTask::resolution setTo resolution.toString(),
AccomPropertyMergeTask::handledBy setTo handledBy
)
complete example here: https://litote.org/kmongo/typed-queries/
Note: this doesn't automatically add __lut field!
Disclaimer: Since we are not officialy supported by #backend-infra, please test your kotlin codes before deploying them to prod
Feel free to start a thread containing suggestions/fixes