CRUD operations
To be able to perform CRUD operations with our data, we have to implement some code. We will make the necessary changes and introduce some new classes. What we will present to you now is a standard for every Spring application that manipulates the data stored in the relational database.
Create a package named repository
with the NoteRepository
interfaces as follows:
package com.journaler.api.repository import com.journaler.api.data.Note import org.springframework.data.repository.CrudRepository /** * String is the type for ID we use. */ interface NoteRepository : CrudRepository<Note, String> TodoRepository: package com.journaler.api.repository import com.journaler.api.data.Todo import org.springframework.data.repository.CrudRepository /** * String is the type for ID we use. */ interface TodoRepository : CrudRepository<Todo, String>
Both interfaces inherit CrudRepository
. CrudRepository
brings us the following functionalities:
save()
: Saving...