Skip to content

RanAwaySuccessfully/node-odata-parser

 
 

Repository files navigation

OData query string parser for node.js based on pegjs.

Fork with added support for the IN filter.

Installation

npm install git+https://github.com/RanAwaySuccessfully/node-odata-parser

Usage

var parser = require("odata-parser");

var ast = parser.parse("$top=10&$skip=5&$select=foo")

util.inspect(ast)

will result in:

{
  '$top': 10,
  '$skip': 5,
  '$select': [ 'foo' ]
}

Filters like:

parser.parse("$filter=Name eq 'John' and LastName lt 'Doe'")

results in:

{
    $filter: {
        type: 'and',
        left: {
            type: 'eq',
            left: {
                type: 'property',
                name: 'Name'
            },
            right: {
                type: 'literal',
                value: 'John'
            }
        },
        right: {
            type: 'lt',
            left: {
                type: 'property',
                name: 'LastName'
            },
            right: {
                type: 'literal',
                value: 'Doe'
            }
        }
    }
}

Using functions in filters

parser.parse("$filter=substringof('nginx', Servers)")

restuls in:

{
    $filter: {
        type: 'functioncall',
        func: 'substringof',
        args: [{
            type: 'literal',
            value: 'nginx'
        }, {
            type: 'property',
            name: 'Servers'
        }]
    }
}

Author

Auth0 with additional contributors

License

This project is licensed under the MIT license. See the LICENSE file for more info.

About

OData query string parser for node.js.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 54.8%
  • PEG.js 45.2%