Skip to content

Commit

Permalink
Adds an "ends with" filter for string queries (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Overloop authored and drew-gross committed Sep 22, 2016
1 parent 346fcb0 commit e369183
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/Filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export const Constraints = {
starts: {
name: 'starts with',
},
ends: {
name: 'ends with',
},
before: {
name: 'is before',
field: 'Date',
Expand Down Expand Up @@ -89,7 +92,7 @@ export const FieldConstraints = {
'Pointer': [ 'exists', 'dne', 'eq', 'neq'],
'Boolean': [ 'exists', 'dne', 'eq' ],
'Number': [ 'exists', 'dne', 'eq', 'neq', 'lt', 'lte', 'gt', 'gte' ],
'String': [ 'exists', 'dne', 'eq', 'neq', 'starts' ],
'String': [ 'exists', 'dne', 'eq', 'neq', 'starts', 'ends' ],
'Date': [ 'exists', 'dne', 'before', 'after' ],
'Array': [
'exists',
Expand Down
3 changes: 3 additions & 0 deletions src/lib/queryFromFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ function addConstraint(query, filter) {
case 'starts':
query.startsWith(filter.get('field'), filter.get('compareTo'));
break;
case 'ends':
query.endsWith(filter.get('field'), filter.get('compareTo'));
break;
case 'before':
query.lessThan(filter.get('field'), filter.get('compareTo'));
break;
Expand Down

0 comments on commit e369183

Please sign in to comment.