Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@bitovi/objection-querystring-parser
Advanced tools
This library builds on top of [`@bitovi/querystring-parser`](https://github.com/bitovi/querystring-parser/tree/main/packages/querystring-parser#readme) to transform CRUD-related querystrings into structured data for the [Objection ORM](https://vincit.gith
This library builds on top of @bitovi/querystring-parser
to transform CRUD-related querystrings into structured data for the Objection ORM.
npm install @bitovi/objection-querystring-parser
If you do not plan to use this library with Objection, please install @bitovi/querystring-parser
.
fx
, isNested
and a parameters
key in the format { fx: 'limit', isNested: false, parameters: [10] }fx
is the name of the function to be chained to the queryisNested
is a boolean that indicates if a Query is Nested(AND, OR, NOT).parameters
where isNested
is true is an array of results each with its own fx
, isNested
and parameters
.parameters
where isNested
is false is an array of parameters to be added to the function fx
, the parameters value is an array that you would spread into your function fx
.Query[fx1](...parameters1)[fx2](...parameters2)
.const querystringParser = require("@bitovi/objection-querystring-parser");
Reference: JSON:API - Sorting
const result = querystringParser.parse("sort=-date,name");
console.log(result);
// {
// orm: "objection",
// data: [
// {
// fx: "orderBy",
// parameters: [[
// { column: "date", order: "DESC" },
// { column: "name", order: "ASC" },
// ]],
// }
// ],
// errors: [],
// };
Reference: JSON:API - Pagination
const result = querystringParser.parse("page[number]=1&page[size]=10");
console.log(result);
// {
// orm: "objection",
// data: [
// [
// {
// fx: "offset",
// isNested: false,
// parameters: [0],
// },
// {
// fx: "limit",
// isNested: false,
// parameters: [10],
// },
// ],
// ],
// errors: [],
// };
Reference: JSON:API - Inclusion of Related Resources
const result = querystringParser.parse("fields[people]=id,name");
console.log(result);
// {
// orm: "objection",
// data: [
// [
// {
// fx: "select",
// isNested: false,
// parameters: ["id","name"],
// },
// ],
// ],
// errors: [],
// };
Reference: JSON:API - Inclusion of Related Resources
const result = querystringParser.parse("include=pets,dogs");
console.log(result);
// {
// orm: "objection",
// data: [
// [
// {
// fx: "withGraphFetched",
// isNested: false,
// parameters: ["pets", "dogs"],
// },
// ],
// ],
// errors: [],
// };
const result = querystringParser.parse(
"filter=or(any(age,'10','20'),equals(name,'mike'))"
);
console.log(result);
// {
// orm: "objection",
// data: [
// {
// fx: "where",
// isNested: true,
// parameters: [
// {
// fx: "whereIn",
// isNested: false,
// parameters: ["age", [10, 20]],
// },
// {
// fx: "orWhere",
// parameters: ["name", "=", "mike"],
// },
// ],
// },
// ],
// errors: [],
// };
const result = querystringParser.parse(
"filter=not(lessOrEqual(age,'10'),equals(name,null))"
);
console.log(result);
// {
// orm: "objection",
// data: [
// {
// fx: "whereNot",
// isNested: true,
// parameters: [
// {
// fx: "where",
// isNested: false,
// parameters: ["age", "<=", 10],
// },
// {
// fx: "whereNull",
// parameters: ["name"],
// },
// ],
// },
// ],
// errors: [],
// };
Note: Database Validations should be done before or after passing the query to the library before the database call is made.
A more practical example on how to use this library in your project can be found here.
This library builds on @bitovi/querystring-parser
. See its documentation for more on using querystring-parser
.
FAQs
This library builds on top of [`@bitovi/querystring-parser`](https://github.com/bitovi/querystring-parser/tree/main/packages/querystring-parser#readme) to transform CRUD-related querystrings into structured data for the [Objection ORM](https://vincit.gith
The npm package @bitovi/objection-querystring-parser receives a total of 1 weekly downloads. As such, @bitovi/objection-querystring-parser popularity was classified as not popular.
We found that @bitovi/objection-querystring-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 15 open source maintainers 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.