Limit object creation in getNotes
This commit is contained in:
parent
feeee20bfe
commit
6e4fa89e85
@ -25,19 +25,14 @@ class NotesService(override val kodein: Kodein) : KodeinAware {
|
||||
.where { Notes.userId eq userId }
|
||||
.orderBy(Notes.updatedAt.desc())
|
||||
.map { row ->
|
||||
Notes.createEntity(row)
|
||||
}
|
||||
.toList()
|
||||
.map { note ->
|
||||
val tags = db.from(Tags)
|
||||
.select(Tags.name)
|
||||
.where { Tags.noteId eq note.id }
|
||||
.where { Tags.noteId eq row[Notes.id]!! }
|
||||
.map { it[Tags.name]!! }
|
||||
.toList()
|
||||
|
||||
val updatedAt = DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(note.updatedAt)
|
||||
val updatedAt = DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(row[Notes.updatedAt]!!)
|
||||
|
||||
NotesDTO(note.title, tags, updatedAt)
|
||||
NotesDTO(row[Notes.title]!!, tags, updatedAt)
|
||||
}
|
||||
|
||||
fun getNoteIdFromUserIdAndTitle(userId: Int, noteTitle: String): Int? = db.from(Notes)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user