dev.krud.crudframework.mongo.dao.MongoCrudDaoImpl.kt Maven / Gradle / Ivy
package dev.krud.crudframework.mongo.dao
import dev.krud.crudframework.crud.handler.CrudDao
import dev.krud.crudframework.model.BaseCrudEntity
import dev.krud.crudframework.modelfilter.DynamicModelFilter
import java.io.Serializable
class MongoCrudDaoImpl : CrudDao, AbstractMongoBaseDao() {
override fun ?, Filter : DynamicModelFilter> index(filter: Filter, clazz: Class): MutableList {
val query = buildQuery(filter)
setOrder(query, filter.orders)
setBoundaries(query, filter.start?.toInt(), filter.limit?.toInt())
return mongoTemplate.find(query, clazz)
}
override fun ?, Filter : DynamicModelFilter?> indexCount(filter: Filter, clazz: Class): Long {
return mongoTemplate.count(buildQuery(filter), clazz)
}
override fun ?> hardDeleteById(id: ID, clazz: Class?) {
deleteObject(clazz, id)
}
override fun > saveOrUpdate(entity: Entity): Entity {
mongoTemplate.save(entity)
return entity
}
override fun > saveOrUpdate(entities: List): List {
entities.forEach { mongoTemplate.save(it) }
return entities
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy