I’m working with node and mongo 5. I am trying to select the field "TOTAL DUE" with a value other than ‘$0.00’ . I think I’m able to select for ‘$0.00’ with:
{'TOTAL DUE': {$regex: /$0./}}
as in the screenshot. However trying to negate this with:
{'TOTAL DUE': {$not :{$regex: /$0./}}}
gives the entire data set (including when TOTAL DUE does not exist),
How can I get this working?
edit:
[
{
"_id": {
"$oid": "6386d07324da3f53abd52449"
},
"RowId": 0,
"ParcelUse": "2",
"UseDefinition": "",
"TotalFCV": 22400,
"Map": 0,
"Plat": 0,
"lat": 32.44123,
"long": -110.7572,
"zip": "85712-5433",
"totalDue": 0,
"AMOUNT": "$0.00",
"CERT NO ": "",
"FEES": "$0.00",
"INTEREST": "$0.00",
"INTEREST DATE": "",
"INTERESTPERCENT": "",
"PAY": "",
"PENALTIES": "$0.00",
"TAX YEAR": "",
"TOTAL DUE": "$0.00"
}
]
2
Answers
It turned out that what worked in my case was:
The problem must be that not all over the documents had the 'TOTAL DUE' field. I didn't know that this would be a problem.
Matching just
/$0./
will miss values less than $1.If the zero due string will always be
"$0.00"
, you can use an inequality match like:Playground