1.0.3 • Published 5 months ago

@licheng5625/odata-parser v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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

Fork with added support for the IN filter. Add uuid and $count=truefor odata v4.0 querys.

Installation

npm install @seamapi/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

Forked by Seam

License

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

1.0.3

5 months ago