# thindb

> NODEJS通用数据库访问和操作组件，如mysql、redis等

Latest version **1.1.12** (published 2023-07-23) · ISC license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.12 |
| Published | 2023-07-23 |
| First published | 2023-06-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=15.0.0 |
| Dependencies | 2 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Juuen |
| Maintainers | juuenlee |
| Keywords | thindb, mysql, redis |

## Links

- npm: https://www.npmjs.com/package/thindb
- Homepage: https://github.com/Juuen/thindb#readme
- npm.io page: https://npm.io/package/thindb

## Dependencies (2)

- [mysql2](https://npm.io/package/mysql2.md) ^3.4.2
- [ioredis](https://npm.io/package/ioredis.md) ^5.3.2

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.1.12 (latest) — 2023-07-23
- 1.1.10 — 2023-07-12
- 1.1.4 — 2023-07-09
- 1.0.10 — 2023-07-05
- 1.0.8 — 2023-07-05
- 1.0.6 — 2023-06-30

## README

# thindb

基于 Nodejs 的通用数据库访问和操作组件，如 mysql、redis 等

# Install

```console
npm install thindb
```

# Usage

实例化

```console
const Thindb = require("thindb");
const thindb = new Thindb([...config]);

```

## mysql

### 单数据库引用

```console
let ddd=thindb.mysql.ddd();
ddd.execPromise({sp:"",token:"",data:""});
```

### 多数据库引用

```console
let ddd=thindb.mysql.ddd();
ddd.execPromise({sp:"",token:"",data:""});

let ddd2=thindb.mysql.ddd("[poolName2]");
ddd2.execPromise({sp:"",token:"",data:""});

// 注：一般来说poolName值等于配置文件里面的database值
```

### global 变量引用

```console
// 当有多个数据库时候，该方式会选择配置里第一顺位数据库连接
global.ddd_mysql.exePromise({sp:"",token:"",data:""});
```

### 配置文件样例

```json
{
	"dbconfig": [
		{
			"mysql": {
				"host": "[host]",
				"port": "[port]",
				"database": "[database]",
				"user": "[user]",
				"password": "[password]"
			}
		},
		{
			"mysql": {
				"host": "[host2]",
				"port": "[port2]",
				"database": "[database2]",
				"user": "[user2]",
				"password": "[password2]"
			}
		}
	]
}
```

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