Skip to content

Commit

Permalink
perf(repository): prevent multiple array allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaty authored and raymondfeng committed Oct 16, 2018
1 parent 90c4406 commit 691981c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/repository/src/query.ts
Expand Up @@ -583,17 +583,21 @@ export class FilterBuilder<MT extends object = AnyObject> {
} else {
if (isFilter(constraint)) {
// throw error if imposed Filter has non-where fields
Object.keys(constraint).forEach(key => {
if (
['fields', 'order', 'limit', 'skip', 'offset', 'include'].includes(
key,
)
) {
const nonWhereFields = [
'fields',
'order',
'limit',
'skip',
'offset',
'include',
];
for (const key of Object.keys(constraint)) {
if (nonWhereFields.includes(key)) {
throw new Error(
'merging strategy for selection, pagination, and sorting not implemented',
);
}
});
}
}
this.filter.where = isFilter(constraint)
? new WhereBuilder(this.filter.where).impose(constraint.where!).build()
Expand Down

0 comments on commit 691981c

Please sign in to comment.