Skip to content

Commit

Permalink
filtering null values only
Browse files Browse the repository at this point in the history
  • Loading branch information
sadakchap committed Jun 3, 2021
1 parent b53fd00 commit 38d2f16
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib/queryFromFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function queryFromFilters(className, filters) {
query = className.query();
}
filters.forEach((filter) => {
addConstraint(query, filter);
query = addConstraint(query, filter, className);
});
return query;
}
Expand All @@ -28,7 +28,7 @@ function addQueryConstraintFromObject(query, filter, constraintType) {
}
}

function addConstraint(query, filter) {
function addConstraint(query, filter, className) {
switch (filter.get('constraint')) {
case 'exists':
query.exists(filter.get('field'));
Expand Down Expand Up @@ -105,7 +105,10 @@ function addConstraint(query, filter) {
addQueryConstraintFromObject(query, filter, 'lessThanOrEqualTo');
break;
case 'isNull':
query.equalTo(filter.get('field'), null);
query.exists(filter.get('field'));
let nullQuery = new Parse.Query(className);
nullQuery.equalTo(filter.get('field'), null);
query = Parse.Query.and(query, nullQuery);
break;
}
return query;
Expand Down

0 comments on commit 38d2f16

Please sign in to comment.