Skip to content

Commit

Permalink
Merge whitelist to always include (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl authored Oct 7, 2019
1 parent fda4b02 commit 65d5685
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ class Service extends AdapterService {
throw new Error('You must provide a Mongoose Model');
}

const { whitelist = ['$regex'] } = options;

super(Object.assign({
id: '_id',
whitelist: ['$and', '$regex'],
filters: Object.assign({
$populate (value) {
return value;
}
}, options.filters)
}, options));
}, options, {
whitelist: whitelist.concat('$and')
}));

this.discriminatorKey = this.Model.schema.options.discriminatorKey;
this.discriminators = {};
Expand Down
4 changes: 4 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ describe('Feathers Mongoose Service', () => {
expect(people.id).to.equal('_id');
});

it('merges whitelist parameters (#347)', () => {
expect(people.options.whitelist).to.deep.equal(['$populate', '$and']);
});

it('when missing the overwrite option sets the default to be true', () => {
expect(people.overwrite).to.be.true;
});
Expand Down

0 comments on commit 65d5685

Please sign in to comment.