/odata-v4-filter-parser

odata-v4-filter-parser is a JS parser which parses OData V4 $filter syntax in URL into MongoDB syntax.

Primary LanguageJavaScript

odata-v4-filter-parser is a JS parser which parses OData V4 $filter syntax in URL into MongoDB syntax.

See

Usage

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"
      }
    }
  ]
}

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section.

License

This project is licensed under the MIT license.