Skip to content

Commit 691981c

Browse files
Yatyraymondfeng
authored andcommitted
perf(repository): prevent multiple array allocation
1 parent 90c4406 commit 691981c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

packages/repository/src/query.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -583,17 +583,21 @@ export class FilterBuilder<MT extends object = AnyObject> {
583583
} else {
584584
if (isFilter(constraint)) {
585585
// throw error if imposed Filter has non-where fields
586-
Object.keys(constraint).forEach(key => {
587-
if (
588-
['fields', 'order', 'limit', 'skip', 'offset', 'include'].includes(
589-
key,
590-
)
591-
) {
586+
const nonWhereFields = [
587+
'fields',
588+
'order',
589+
'limit',
590+
'skip',
591+
'offset',
592+
'include',
593+
];
594+
for (const key of Object.keys(constraint)) {
595+
if (nonWhereFields.includes(key)) {
592596
throw new Error(
593597
'merging strategy for selection, pagination, and sorting not implemented',
594598
);
595599
}
596-
});
600+
}
597601
}
598602
this.filter.where = isFilter(constraint)
599603
? new WhereBuilder(this.filter.where).impose(constraint.where!).build()

0 commit comments

Comments
 (0)