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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.172.38