odata-v4-filter-parser is a JS parser which parses OData V4 $filter syntax in URL into MongoDB syntax.
See
const { parse } = require('odata-v4-filter-parser');
parse("(status eq Enum.Status'ACTIVE' or status eq Enum.Status'DELETED') and id eq 11 and contains(text, 'aa') and (score/overall gt 123) and isof(data, Model.DevcieData)");
results in
{
"$and": [
{
"$or": [
{
"status": {
"$eq": "ACTIVE"
}
},
{
"status": {
"$eq": "DELETED"
}
}
]
},
{
"id": {
"$eq": 11
}
},
{
"text": {
"$regex": ".*aa.*"
}
},
{
"score.overall": {
"$gt": 123
}
},
{
"data": {
"$type": "Model.DevcieData"
}
}
]
}
If you have found a bug or if you have a feature request, please report them at this repository issues section.
This project is licensed under the MIT license.