Creating a user repository

We will communicate with the database in this class. This is a repository class and so we annotate this class with @Repository. Let's create a repository class named UserRepository.kt, which implements the UsersInterface.

Here is the code of the repository class:

@Repository
class UserRepository: UsersInterface {

override fun getAllUserList(): List<UserModel> {
}

override fun getUserByID(id: Int): UserModel? {
}

override fun addNewUser(userModel: UserModel) {
}

override fun updateUser(userModel: UserModel) {
}

override fun deleteUser(id: Int) {
}
}

We have created a repository class named UserRepository, where we implement UsersInterface, and override all the functions of the interface. We use the @Repository annotation to make it a repository class.

Let's complete this class step by step in the following section.