package ovh.herisson.Clyde.Repositories;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import ovh.herisson.Clyde.Tables.User;

public interface UserRepository extends CrudRepository<User, Long> {

    User findById(long id);

    User findByEmail(String email);



    @Query("select u from User u where u.role = ovh.herisson.Clyde.Tables.Role.Teacher")
    Iterable<User> findAllTeachers();

    @Query("select u from User u where u.role = ovh.herisson.Clyde.Tables.Role.Student")
    Iterable<User> findAllStudents();

    @Query("select u from User u where u.role <> ovh.herisson.Clyde.Tables.Role.Admin")
    Iterable<User> findAllExceptAdmins();
}