# @kiza/utils

> Mysql utilities for Node.js

Latest version **5.2.0** (published 2026-02-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @kiza/utils
pnpm add @kiza/utils
yarn add @kiza/utils
bun add @kiza/utils
```

## Health

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

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 5.2.0 |
| Published | 2026-02-16 |
| First published | 2020-06-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kiza |
| Maintainers | kiza |

## Links

- npm: https://www.npmjs.com/package/@kiza/utils
- Repository: https://github.com/K1Z4/Utils
- Homepage: https://github.com/K1Z4/Utils#readme
- Issues: https://github.com/K1Z4/Utils/issues
- npm.io page: https://npm.io/package/@kiza/utils

## Recent versions

- 5.2.0 (latest) — 2026-02-16
- 5.1.0 — 2024-07-09
- 5.0.0 — 2024-07-09
- 4.0.1 — 2023-12-28
- 4.0.0 — 2023-12-27
- 3.0.0 — 2023-08-08
- 2.0.3 — 2023-08-07
- 2.0.2 — 2023-04-15
- 2.0.1 — 2023-04-15
- 2.0.0 — 2023-04-15
- 1.2.0 — 2022-03-31
- 1.1.0 — 2020-10-10
- 1.0.0 — 2020-06-20

## README

# Utils
Mostly mysql utilities for Node.js

```bash
npm install @kiza/utils
```

## Setup connection string

Run once on startup:

```js
import { poolProvider } from "@kiza/utils";
import mysql from 'mysql2/promise';
import config from "config";

await poolProvider.setPool(() => mysql.createPool(config.database));
```

Example of config: 

```json
{
    "host": "localhost",
    "user": "root",
    "password": "password",
    "database": "mydb",
    "dateStrings": true,
    "port": 3306,
    "charset": "utf8mb4"
}
```

## Use mysqlBase

See example in testApp.js

Create your repositories like:

```js
import { mysqlBase } from "@kiza/utils";

export default class extends mysqlBase {
    static getJobs(siteId) {
        return this.all("SELECT * FROM job WHERE siteId = ? ORDER BY posted DESC", [siteId]);
    }
}
```

Transactions:

```js
import { mysqlBase } from "@kiza/utils";

export default class extends mysqlBase {
    static addJobs(job, job2) {
        return this.inTransacation(async con => {
            await this.insert("INSERT INTO job SET ?", job, con);
            await this.insert("INSERT INTO job SET ?", job2, con);
        });
    }
}
```

## Publish package

Note to self

```bash
npm publish --access public
```

## Change log

### v5

- Remove dep on mysql2 package, pool should be provided by consumer. This lets the consumer manage the mysql version
- Remove guid util. node:crypto should be used instead

### v4

- BIT maps to boolean automatically

### v3 

- moved es6 imports

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