https://kotlinlang.org logo
#exposed
Title
# exposed
t

tapac

12/27/2017, 10:00 PM
@damian, I think you doing it right, but you might replace
dao.dependsOnTable.select {...}
with
dao.searchQuery{...}
. And ofc making query with order by and limit is much faster and effective than loading everything into memory, but don’t forget to add index to updated_at if you have large table.
d

damian

12/27/2017, 10:07 PM
thanks. i've added the incides. i've never used
searchQuery
before, could you give me a pointer on how i could solve this with
searchQuery
?
t

tapac

12/27/2017, 11:21 PM
searchQuery
do the same: returns Query with slice on dependsOnTable. This function used when you use find/getById functions. in special cases someone could override that function to add additional conditions to every select, so using searchQuery directly instead of using depensOnTable is prefered.
d

damian

12/27/2017, 11:28 PM
so it'd be
dao.wrapRows(dao.searchQuery(op.build { row = myCondition }).orderBy()...
? i don't really know what the
wrapRows
does, i think i haven't found a good documentation of this yet. i saw it in a project on github and its working, but no idea why.
t

tapac

12/28/2017, 9:53 AM
wrapRows create lazy iterable of entities (dao in your case) over resultset from database.
o

oshai

12/28/2017, 3:00 PM
do you think it should be on docs?
t

tapac

12/28/2017, 9:43 PM
I think information about overriding dependsOnTable/column and searchQuery should be present in docs, but it's "advanced technics", which must be described with good real-world examples. But i think, that having in docs the way how you can create entities from Query is very plesant
2 Views