Added findBy methods to cover unique indices

This commit is contained in:
2023-10-26 19:16:34 +02:00
parent b3a55af93a
commit ae358fd690
3 changed files with 17 additions and 5 deletions
@@ -1,7 +1,10 @@
package de.twomartens.timetable.bahnApi.repository package de.twomartens.timetable.bahnApi.repository
import de.twomartens.timetable.bahnApi.model.Eva
import de.twomartens.timetable.bahnApi.model.db.BahnStation import de.twomartens.timetable.bahnApi.model.db.BahnStation
import org.bson.types.ObjectId
import org.springframework.data.mongodb.repository.MongoRepository import org.springframework.data.mongodb.repository.MongoRepository
// TODO: figure out what ID type should be interface BahnStationRepository : MongoRepository<BahnStation, ObjectId> {
interface BahnStationRepository : MongoRepository<BahnStation, String> fun findByEva(eva: Eva): BahnStation?
}
@@ -1,7 +1,12 @@
package de.twomartens.timetable.bahnApi.repository package de.twomartens.timetable.bahnApi.repository
import de.twomartens.timetable.bahnApi.model.Eva
import de.twomartens.timetable.bahnApi.model.db.BahnTimetable import de.twomartens.timetable.bahnApi.model.db.BahnTimetable
import de.twomartens.timetable.types.HourAtDay
import org.bson.types.ObjectId
import org.springframework.data.mongodb.repository.MongoRepository import org.springframework.data.mongodb.repository.MongoRepository
// TODO: figure out what ID type should be // TODO: figure out what ID type should be
interface BahnTimetableRepository : MongoRepository<BahnTimetable, String> interface BahnTimetableRepository : MongoRepository<BahnTimetable, ObjectId> {
fun findByEvaAndHourAtDay(eva: Eva, hourAtDay: HourAtDay): BahnTimetable?
}
@@ -1,7 +1,11 @@
package de.twomartens.timetable.bahnApi.repository package de.twomartens.timetable.bahnApi.repository
import de.twomartens.timetable.bahnApi.model.Eva
import de.twomartens.timetable.bahnApi.model.db.ScheduledFetchTask import de.twomartens.timetable.bahnApi.model.db.ScheduledFetchTask
import de.twomartens.timetable.types.HourAtDay
import org.bson.types.ObjectId
import org.springframework.data.mongodb.repository.MongoRepository import org.springframework.data.mongodb.repository.MongoRepository
// TODO: what should be ID type be? interface ScheduledFetchTaskRepository : MongoRepository<ScheduledFetchTask, ObjectId> {
interface ScheduledFetchTaskRepository : MongoRepository<ScheduledFetchTask, String> fun findByEvaAndFetchedDateTime(eva: Eva, fetchedDateTime: HourAtDay): ScheduledFetchTask?
}