
Research
/Security News
11 Malicious NuGet Tools Pose as Game Cheats to Drop a Windows Host-Surveillance Payload
11 malicious NuGet tools pose as game cheats to deploy Windows payloads, track hosts, and use Google Sheets for telemetry and control.
odata4querybuilder
Advanced tools
An eloquently fluent OData query builder.
yarn add odata-query-builder
or
npm install --save odata-query-builder
const query = new QueryBuilder()
.count()
.top(5)
.skip(5)
.expand('NavigationProp')
.orderBy('MyPriorityProp')
.filter(f => f.filterExpression('Property', 'eq', 'MyValue'))
.toQuery()
Outputs:
?$orderby=MyPriorityProp&$top=5&$skip=5&$count=true&$expand=NavigationProp&$filter=Property eq 'MyValue'
Filter expresssions utilize logical operators to filter data on a specific property.
Operator Options:
eqnegtgeltleconst query = new QueryBuilder()
.filter(f =>
f.filterExpression('Property1', 'eq', 'Value1')
).ToQuery();
Outputs: ?$filter=Property1 eq 'Value1'
Filter phrases are meant to be used with canonical functions. Filter Phrasing exposes the filter as a string which allows you to inject any of the various filtering mechanisms available in OData v4.
Below are a few examples:
const query = new QueryBuilder()
.filter(f =>
.filter(f =>
f
.filterPhrase(`contains(Property1,'Value1')`)
.filterPhrase(`startswith(Property1,'Value1')`)
.filterPhrase(`endswith(Property1,'Value1')`)
.filterPhrase(`indexOf(Property1,'Value1') eq 1`)
.filterPhrase(`length(Property1) eq 19`)
.filterPhrase(`substring(Property1, 1, 2) eq 'ab'`)
).ToQuery();
Outputs: ?$filter=contains(Property1,'Value1') and startswith(Property1,'Value1') and endswith(Property1,'Value1') and indexOf(Property1,'Value1') eq 1 and length(Property1) eq 19 and substring(Property1, 1, 2) eq 'ab
By default when you utilize .filter you are using the and operator. You can be explict by passing your operator into the filter as a secondary parameter.
const query = new QueryBuilder().filter(f => f
.filterExpression('Property1', 'eq', 'Value1')
.filterExpression('Property2', 'eq', 'Value1'),
'and'
).toQuery();
Outputs: ?$filter=Property1 eq 'Value1' and Property2 eq 'Value1'
const query = new QueryBuilder().filter(f => f
.filterExpression('Property1', 'eq', 'Value1')
.filterExpression('Property2', 'eq', 'Value1'),
'or'
).toQuery();
Outputs: ?$filter=Property1 eq 'Value1' or Property2 eq 'Value1'
Nested or grouped filtering is used when we need to write a more complex filter for a data set. This can be done by utilizing .and() or .or() with the filter.
const query = new QueryBuilder().filter(f => f
.filterExpression('Property1', 'eq', 'Value1')
.filterExpression('Property2', 'eq', 'Value2')
.and(f1 => f1
.filterExpression('Property3', 'eq', 'Value3')
.filterExpression('Property4', 'eq', 'Value4')
)
).toQuery();
Outputs: ?$filter=Property1 eq 'Value1' and Property2 eq 'Value2' and (Property3 eq 'Value3' and Property4 eq 'Value4')
const query = new QueryBuilder().filter(f => f
.filterExpression('Property1', 'eq', 'Value1')
.filterExpression('Property2', 'eq', 'Value2')
.or(f1 => f1
.filterExpression('Property3', 'eq', 'Value3')
.filterExpression('Property4', 'eq', 'Value4')
)
).toQuery();
Outputs: ?$filter=Property1 eq 'Value1' and Property2 eq 'Value2' and (Property3 eq 'Value3' or Property4 eq 'Value4')
const query = new QueryBuilder().filter(f => f
.filterExpression('Property1', 'eq', 'Value1')
.filterExpression('Property2', 'eq', 'Value2')
.or(f1 => f1
.filterExpression('Property3', 'eq', 'Value3')
.filterExpression('Property4', 'eq', 'Value4')
),
'and'
).toQuery();
Outputs: ?$filter=Property1 eq 'Value1' and Property2 eq 'Value2' and (Property3 eq 'Value3' or Property4 eq 'Value4')
FAQs
An eloquently fluent OData query builder.
The npm package odata4querybuilder receives a total of 5 weekly downloads. As such, odata4querybuilder popularity was classified as not popular.
We found that odata4querybuilder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
11 malicious NuGet tools pose as game cheats to deploy Windows payloads, track hosts, and use Google Sheets for telemetry and control.

Research
/Security News
4 compromised asyncapi packages deliver miasma botnet loader on macOS, Linux and Windows.

Research
/Security News
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.