Before we finish this chapter, we will introduce database queries to you. We will define several API calls that will trigger queries defined by us. Writing queries is simple. There are several ways to it. We will present the most common methodologies.
In the first example, we will introduce the API call that will query and return to us all the TODOs that are scheduled later than the date we provide. Open TodoRepository and extend it:
package com.journaler.api.repository import com.journaler.api.data.Todo import org.springframework.data.jpa.repository.Query import org.springframework.data.repository.CrudRepository /** * String is the type for ID we use. */ interface TodoRepository : CrudRepository<Todo, String> { @Query("from Todo t where t.schedule > ?1") fun findScheduledLaterThan(date: Long): Iterable<Todo...