Skip to content

Instantly share code, notes, and snippets.

@juancho088
Created February 17, 2019 18:12
Show Gist options
  • Save juancho088/89351c7e98780aa57bb402826045f144 to your computer and use it in GitHub Desktop.
Save juancho088/89351c7e98780aa57bb402826045f144 to your computer and use it in GitHub Desktop.
CrudRepository Interface
interface CrudRepository<T, in ID> {
companion object {
const val LIMIT: Int = 50
const val MAX_LIMIT: Int = 100
const val OFFSET: Int = 0
const val MIN_LIMIT: Int = 0
}
fun save(entity: T): T
fun findOne(id: ID): T
fun findAll(filters: Map<String, Any> = mapOf(), limit: Int = LIMIT, offset: Int = OFFSET): Page<T>
fun delete(entity: T)
fun exists(id: ID)
fun count(): Int
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment