Skip to content

How do I implement additional features in existing operators? #681

Closed
@felipefreitasnet

Description

@felipefreitasnet

Hello,

I am facing a small problem with mongodb.
I use the jquery Query Builder to generate my queries in mongodb, however in my collection I have some columns of the object type, and my query needs to be able to check if the value actually exists.
For example:

{"$and":[{"custom_tags.lead.EMAILADD.value":{"$ne":""}}]}

This is the code that the querybuilder generates for me.

The problem is that there will not always be any columns, for example that part in bold does not exist. This code in mongodb returns "true"
I need my querybuilder, in the "is_not_empty" option also check if it exists, like this:

{"$and":[{"custom_tags.lead.EMAILADD.value":{"$exists": true, "$ne":""}}]}

I made this modification:

my_builder.queryBuilder({        
                ...
                mongoOperators: {
                    is_not_empty:  function(v) { return { '$exists': true, '$ne': '' }; },
                }
                ...
});

Apparently everything worked as it should, the problem is being setRulesFromMongo

my_builder.queryBuilder('setRulesFromMongo', rules);

image

How do I implement additional features in existing operators?

Thank you and sorry for my english...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions