@bitovi/sequelize-querystring-parser

中文文档
0.3.6发布于 2024/03/19MITCommonJS近 30 天下载 4854

This library builds on top of @bitovi/querystring-parser to transform CRUD-related querystrings into structured data for the [Sequelize ORM](https://sequelize.o

原始使用文档
文档目录9 节
  1. Installation
  2. Usage
  3. Sort Parameters
  4. Pagination Parameters
  5. Fields Parameters
  6. Include Parameters
  7. Filter Parameters
  8. Example
  9. Further Documentation

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.

版本与发布记录

@bitovi/sequelize-querystring-parser 共发布 39 个版本,首次发布于 2022/08/02;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.3.6latest2024/03/192 年前
0.3.52024/03/162 年前
0.3.42024/03/162 年前
0.3.32023/12/272 年前
0.3.22023/12/142 年前
0.3.12023/12/082 年前

关于 @bitovi/sequelize-querystring-parser 的常见问题

@bitovi/sequelize-querystring-parser 是什么?

This library builds on top of @bitovi/querystring-parser to transform CRUD-related querystrings into structured data for the [Sequelize ORM](https://sequelize.o

如何安装 @bitovi/sequelize-querystring-parser?

在项目目录运行 npm install @bitovi/sequelize-querystring-parser,或使用 pnpm add / yarn add / bun add。

@bitovi/sequelize-querystring-parser 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/bitovi__sequelize-querystring-parser 是否存在。

@bitovi/sequelize-querystring-parser 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@bitovi/sequelize-querystring-parser 可以商用吗?

@bitovi/sequelize-querystring-parser 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bitovi/sequelize-querystring-parser 的下载量有多少?

根据 npm 官方下载统计,@bitovi/sequelize-querystring-parser 在 2026/10/08 – 2026/11/06 这 30 天内被下载 4,854 次,日均约 162 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bitovi/sequelize-querystring-parser 还在维护吗?

最新版本 0.3.6 发布于 2024/03/19(2 年前);至今共发布 39 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/08/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。