Skip to content

Instantly share code, notes, and snippets.

@GoodnessEzeokafor
Created September 15, 2024 11:09
Show Gist options
  • Save GoodnessEzeokafor/3b928a3f0d9fcb3894e424fec36aeb9c to your computer and use it in GitHub Desktop.
Save GoodnessEzeokafor/3b928a3f0d9fcb3894e424fec36aeb9c to your computer and use it in GitHub Desktop.
const { data, pagination } =
await this.data.transactions.findAllWithPagination(
{
...filterQuery,
isRevenue: false,
reconTransactionType: Not(In(excludedTransactionType)),
},
{
relationFields: ['user'],
selectFields: this.selectFields,
},
);
// in the findAllWithPagination method
const baseFindOptions = {
where: { ...query },
order: {
createdAt: sort,
},
take: perpage,
skip: page * perpage - perpage,
...(options?.relationFields
? { relations: options.relationFields }
: null), // lazy loading in typeORM
...(options?.selectFields ? { select: options.selectFields } : []),
...(options?.relationIds ? { loadRelationIds: true } : false),
// cache: true,
};
const [data, total] = await this._entity.findAndCount(baseFindOptions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment