# j2sql2

> j2sql2自用函数

Latest version **2.0.13** (published 2025-12-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install j2sql2
pnpm add j2sql2
yarn add j2sql2
bun add j2sql2
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 2.0.13 |
| Published | 2025-12-15 |
| First published | 2019-10-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 66.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Kongnet |
| Maintainers | kongnet |

## Links

- npm: https://www.npmjs.com/package/j2sql2
- Repository: https://github.com/kongnet/j2sql2
- Homepage: https://github.com/kongnet/j2sql2#readme
- Issues: https://github.com/kongnet/j2sql2/issues
- npm.io page: https://npm.io/package/j2sql2

## Dependencies (9)

- [dmdb](https://npm.io/package/dmdb.md) ^1.0.43524
- [meeko](https://npm.io/package/meeko.md) ^1.8.298
- [mssql](https://npm.io/package/mssql.md) ^12.0.0
- [mysql2](https://npm.io/package/mysql2.md) ^3.15.3
- [amqplib](https://npm.io/package/amqplib.md) ^0.8.0
- [ioredis](https://npm.io/package/ioredis.md) ^4.14.1
- [bluebird](https://npm.io/package/bluebird.md) ^3.7.1
- [promise-mysql](https://npm.io/package/promise-mysql.md) ^4.1.1
- [amqp-connection-manager](https://npm.io/package/amqp-connection-manager.md) 4.1.10

## Recent versions

- 2.0.13 (latest) — 2025-12-15
- 2.0.12 — 2025-12-15
- 2.0.11 — 2025-12-15
- 2.0.9 — 2025-12-14
- 2.0.8 — 2025-12-14
- 2.0.7 — 2025-12-14
- 2.0.4 — 2025-11-27
- 2.0.3 — 2025-11-27
- 2.0.2 — 2025-11-27
- 2.0.1 — 2025-11-27
- 2.0.0 — 2025-11-26
- 1.9.133 — 2025-10-14
- 1.9.132 — 2024-01-20
- 1.9.131 — 2024-01-20
- 1.9.130 — 2023-04-25
- … 102 more at https://npm.io/package/j2sql2/versions

## README

# j2sql2

enhance j2sql use ioredis mysql2/promise mssql dmdb

###

npm i j2sql2

导入 sample.sql

node sample.js

 > dmdb达梦数据库测试  **目前支持node 16**
 node sample_dm.js

### 关键字和表的冲突

> 不要使用以下关键字作为数据库表名

pool
\_mysql
format
cmd
run
genData

### check 增强

> 在使用对象提交 sql 的情况下,增强如下功能

- 对 where 条件是否有包含此列
- 对 column 是否有包含此列
- 对 order by 是否有包含此列
- 对 string 和 number 类型进行预检测
- 同时封装 mysql 和 redis 详见 sample.js

> 如果数据库配置文件中打开如下配置，将返回和接受，camel 形式的列名，例如 cTime => c_time ..

```javascript
extendOption: {
  columnCamelize: true
}
```

> 如果有 mysql.crudExtend 就扩展 db['tableName'].ex 属性，并检查数据库表是否有如下字段,都基于 d_flag 字段

```javascript
mysql: {
  crudExtend: {
    isDevMode: 1 // 默认开发模式打印sql语句
    /* delflagField: 'd_flag', // 默认逻辑删除标记
      createTimeField: 'c_time',
      modifyTimeField: 'm_time' */
  }
}
```

```javascript
redis: {
  keyLimit: ['x1', 'c*'] // '*' 全部允许
}
// 也可以通过redis实例 redis.keysLimit.add('*') or redis.keysLimit.status = 0 全部允许(关闭过滤)
// 详见 sample.js
```
```javascript
    // reJson 支持    
    let r = (await rd.jset('sky', '.', { 'x': 1 })) 
    console.log('reJson Test', r)
    r = (await rd.jget('sky', '.')) 
    console.log('reJson Test', r)
    
// 详见 sample.js
```
```javascript
 // 创建SkyDB实例
    const skyDB = new SkyDB({
      dmdb: Config.dmdb
    })
    // 创建dmdb实例
    const dm = await skyDB.dmdb

    // 测试增删改查
    let r = await dm.run('select * from test_user where username = ?;', [
      'test5'
    ])
    console.log('Select: ', r, r.length)
```

- 详见 crud.js
- page, 分页
- list,
- insert,
- update,
- remove,
- clear,
- getById,
- removeById,
- deleteById,
- updateById,
- addById 列增加

---
_Source: https://npm.io/package/j2sql2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
