Getting the user list

Find the code snippet for getAllUsers() operation:

// to get all the users details
@GetMapping("/users")
fun getAllUsers(): List<UserModel>{
return userRepository.findAll()
}

The @GetMapping(path = ["/users"]) annotation means it is used to GET a request. Here, we will get a list of the users from the database using findAll() of the UserRepository interface, which implemented JpaRepository. Consequently, we don't need to create a custom interface, unlike JDBC.