@odata-filter/marshalers
v1.0.1
Published
Marshaler utilities for OData filter expressions, including a MongoDB query generator for MikroORM usage.
Maintainers
Readme
OData Filter Marshalers
Installation
See INSTALL.md for full instructions.
Usage
Package Installation
npm i @odata-filter/marshalers --saveBasic Example
import { tokenize, parse } from '@odata-filter/core';
import { toMongoJson } from '@odata-filter/marshalers';
const tokens = tokenize("country/name eq 'US' and age gte 21");
const ast = parse(tokens);
console.log(ast);
/*{
type: 'logical_operator',
value: 'and',
left: {
type: 'comparison_operator',
value: 'eq',
left: { type: 'field', value: 'country/name' },
right: { type: 'string_value', value: 'US' }
},
right: {
type: 'comparison_operator',
value: 'gte',
left: { type: 'field', value: 'age' },
right: { type: 'number_value', value: 21 }
}
}*/
toMongoJson(ast);
/*{
$and: [
{ 'country/name': { $eq: 'US' } },
{ age: { $gte: 21 } }
]
}*/Contributing
See CONTRIBUTING.md for full instructions.
License
See LICENSE for licensing information.
