New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bitovi/sequelize-querystring-parser

Package Overview
Dependencies
Maintainers
15
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bitovi/sequelize-querystring-parser

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 [Sequelize ORM](https://sequelize.o

  • 0.3.6
  • latest
  • npm
  • Socket score

Version published
Maintainers
15
Created
Source

sequelize-querystring-parser

This library builds on top of @bitovi/querystring-parser to transform CRUD-related querystrings into structured data for the Sequelize ORM.

Installation

npm install @bitovi/sequelize-querystring-parser

If you do not plan to use this library with Sequelize, please install @bitovi/querystring-parser.

Usage

const querystringParser = require("@bitovi/sequelize-querystring-parser");

Sort Parameters

References:

const result = querystringParser.parse("sort=-date,name");
console.log(result);
// {
//   orm: "sequelize",
//   data: {
//     order: [["date", "DESC"],["name","ASC"]]
//  },
//   errors: [],
// };

Pagination Parameters

References:

const result = querystringParser.parse("page[number]=1&page[size]=10");
console.log(result);
// {
//   orm: "sequelize",
//   data: {
//     offset: 0,
//     limit: 10
//  },
//   errors: []
// };

Fields Parameters

References:

const result = querystringParser.parse("fields[]=id,name");
console.log(result);
// {
//   orm: "sequelize",
//   data: {
//     attributes: ["id","name"]
//  },
//   errors: []
// };

Include Parameters

References:

const result = querystringParser.parse("include=pets,dogs");
console.log(result);
// {
//   orm: "sequelize",
//   data: {
//     include: [
//       { association: "pets", include: [] },
//       { association: "dogs", include: [] }
//     ]
//  },
//   errors: []
// };

Filter Parameters

References:

const result = querystringParser.parse("filter=and(any('age','10','20'),equals('name','mike'))");
console.log(result);
// {
//   orm: "sequelize",
//   data: {
//     where: {
//       [Symbol(and)] : [
//         {
//           age: {
//             [Symbol(in)]: [10, 20]
//           }
//         },
//         {
//           name: {
//             [Symbol(eq)]: "mike"
//           }
//         }
//       ]
//     }
//  },
//   errors: []
// };

Note: Database Validations should be done before or after passing the query to the library before the database call is made.

Note: The Symbol() calls use the Op imported from the Sequelize library, not the Javascript Symbol class.

Example

A more practical example on how to use this library in your project can be found here

Further Documentation

This library builds on @bitovi/querystring-parser. See its documentation for more on using querystring-parser.

Keywords

FAQs

Package last updated on 18 Mar 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc