Closed maikvortx closed 3 years ago
I think this functionality is very good, but I think it is valid to come with the limit option included.
Hi @jhomarolo !
Something like this:
async findAll({ limit: 0, orderBy: null }) {
const tableFields = this.dataMapper.tableFields()
const ret = await this.runner
.select(tableFields)
.limit(limit);
const entities = []
for (const row of ret) {
if (row === undefined) continue
entities.push(this.dataMapper.toEntity(row))
}
return entities
}
@maikvortx yes, like this. Could you please, add this into your PR?
if you add offset
as well it would be ready to paginate (offset + limit)
Hello @dalssoft! I like the idea of offset. I will implement these solutions and return for validation.
Cool. For a future PR it would be nice to implement similar options ({ orderBy, limit, offset }
) on findBy
Ok!
Hi @jhomarolo ! PR updated with limit paramter.
@dalssoft, the findBy
method can be included in findAll
because the only change is searchTerm
. What do you think about?
@dalssoft, i included find
method and your wrapersfindBy
and findAll
. You can check? Later i will create another PR with query with pages and other functions.
Can we close this issue after PR https://github.com/herbsjs/herbs2knex/pull/13?
Hi!
I think findAll should be like findBy, but changing to return all records, correct?
I'm implementing this solution for getAll():