Open Blackbaud-JasonBodnar opened 2 years ago
I'm using QueryBuilder to create queries for a MongoDB collection. One of the fields in the documents in the collection is amount and it's defined as Decimal128. In order to query it the value needs to be wrapped in NumberDecimal() like:
amount
Decimal128
NumberDecimal()
db.getCollection('transactions').find({"$and":[{"amount":NumberDecimal(99.02)}]})
Is it possible to create a custom type to QueryBuilder applies this to fields where this is necessary?
I tried using valueGetter but it's not working. My filter looks like:
valueGetter
{ id: 'amount', type: 'double', valueGetter: (rule) => { return `NumberDecimal(${rule.$el.find('[name*=_value_]').val()})` } }
If I debug the valueGetter it's returning what I would expect (NumberDecimal(99.02)) but when I get the rules I get null.
NumberDecimal(99.02)
I guess I could change the type to string but then I'd also have to change all the operators to the numeric operators.
string
Is there a better way to do this?
I'm using QueryBuilder to create queries for a MongoDB collection. One of the fields in the documents in the collection is
amount
and it's defined asDecimal128
. In order to query it the value needs to be wrapped inNumberDecimal()
like:Is it possible to create a custom type to QueryBuilder applies this to fields where this is necessary?
I tried using
valueGetter
but it's not working. My filter looks like:If I debug the valueGetter it's returning what I would expect (
NumberDecimal(99.02)
) but when I get the rules I get null.I guess I could change the type to
string
but then I'd also have to change all the operators to the numeric operators.Is there a better way to do this?