tapac

    tapac

    4 years ago
    @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

    4 years ago
    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
    ?
    tapac

    tapac

    4 years ago
    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

    4 years ago
    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.
    tapac

    tapac

    4 years ago
    wrapRows create lazy iterable of entities (dao in your case) over resultset from database.
    oshai

    oshai

    4 years ago
    do you think it should be on docs?
    tapac

    tapac

    4 years ago
    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