Skip to content

Commit

Permalink
Merge pull request #285 from eclipse/evolute-not-query-mongo-db
Browse files Browse the repository at this point in the history
Enhance query to mongodb
  • Loading branch information
otaviojava authored Sep 4, 2024
2 parents 99f2bf4 + d0fd0b1 commit 2a45a43
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.mongodb.client.model.Filters;
import org.bson.conversions.Bson;
import org.eclipse.jnosql.communication.Condition;
import org.eclipse.jnosql.communication.TypeReference;
import org.eclipse.jnosql.communication.ValueUtil;
import org.eclipse.jnosql.communication.semistructured.CriteriaCondition;
Expand All @@ -43,7 +44,17 @@ public static Bson convert(CriteriaCondition condition) {
List<Object> inList = ValueUtil.convertToList(document.value());
yield Filters.in(document.name(), inList.toArray());
}
case NOT -> Filters.not(convert(document.get(CriteriaCondition.class)));
case NOT -> {
var criteriaCondition = document.get(CriteriaCondition.class);
if (Condition.EQUALS.equals(criteriaCondition.condition())) {
Element element = criteriaCondition.element();
if(element.get() == null) {
yield Filters.exists(element.name(), true);
}
yield Filters.ne(element.name(), element.get());
}
yield Filters.not(convert(criteriaCondition));
}
case LIKE -> Filters.regex(document.name(), value.toString());
case AND -> {
List<CriteriaCondition> andList = condition.element().value().get(new TypeReference<>() {
Expand Down

0 comments on commit 2a45a43

Please sign in to comment.