package dev.fyloz.trial.colorrecipesexplorer.repository

import dev.fyloz.trial.colorrecipesexplorer.model.NamedModel
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.repository.NoRepositoryBean

/** Adds support for entities using a name identifier. */
@NoRepositoryBean
interface NamedJpaRepository<E : NamedModel> : JpaRepository<E, Long> {
    /** Checks if an entity with the given [name]. */
    fun existsByName(name: String): Boolean

    /** Gets the entity with the given [name]. */
    fun findByName(name: String): E?

    /** Removes the entity with the given [name]. */
    fun deleteByName(name: String)
}
