Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MongoDB] Update map_contains_value.js to support others operator (<, >, like ...) #37

Open
Kobee1203 opened this issue Feb 22, 2021 · 0 comments
Labels
enhancement New feature or request mongodb

Comments

@Kobee1203
Copy link
Owner

Kobee1203 commented Feb 22, 2021

map_contains_value.js is used to handle Entity fields from Map value
Example:

class Person {
  private Address mainAddress;
  ...
}
class Address {
  private Map<String, RoomDescription> roomDescription;
  ...
}
class RoomDescription {
    private Double area;
    private String floor;
    private Integer windows;
    private RoomType type;
}

Example of query with equals operator:
/search/person?query=mainAddress.roomDescription.value.type='OFFICE'

But we cannot search for other operators
/search/person?query=mainAddress.roomDescription.value.area>20 AND mainAddress.roomDescription.value.area<30
/search/person?query=mainAddress.roomDescription.value.floor LIKE '*first*'
/search/person?query=mainAddress.roomDescription.value.floor ILIKE '*FIRST*'
...

Update the map_contains_value.js file to handle other operators:

function() {
    ...
    var deepIterate = function (obj, path, value, op) {
    ...
    var check = function(obj, value, op) {
        if(op == '=') {
            return obj == value;
        } else if(op == '<') {
           return obj < value;
        }
        ...
    }
    return deepIterate(this, "{PATH}", {VALUE}, {OP});
}

Update MongoQueryBuilder to use map_contains_value.js for other operators

@Kobee1203 Kobee1203 added enhancement New feature or request mongodb labels Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mongodb
Projects
None yet
Development

No branches or pull requests

1 participant