# typed-mysql

> Uses schema-decorator to enforce type-correctness

Latest version **3.2.0** (published 2018-11-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install typed-mysql
pnpm add typed-mysql
yarn add typed-mysql
bun add typed-mysql
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.2.0 |
| Published | 2018-11-29 |
| First published | 2018-03-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 124.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | anyhowstep |
| Maintainers | anyhowstep |

## Links

- npm: https://www.npmjs.com/package/typed-mysql
- Repository: https://github.com/AnyhowStep/typed-mysql
- Homepage: https://github.com/AnyhowStep/typed-mysql#readme
- Issues: https://github.com/AnyhowStep/typed-mysql/issues
- npm.io page: https://npm.io/package/typed-mysql

## Dependencies (4)

- [mysql](https://npm.io/package/mysql.md) ^2.15.0
- [@types/mysql](https://npm.io/package/@types/mysql.md) ^2.15.3
- [schema-decorator](https://npm.io/package/schema-decorator.md) ^2.10.1
- [@anyhowstep/type-util](https://npm.io/package/@anyhowstep/type-util.md) ^1.9.1

## Recent versions

- 3.2.0 (latest) — 2018-11-29
- 3.1.0 — 2018-08-29
- 3.0.0 — 2018-08-07
- 2.6.2 — 2018-06-09
- 2.6.1 — 2018-06-09
- 2.6.0 — 2018-06-09
- 2.5.1 — 2018-05-30
- 2.5.0 — 2018-05-25
- 2.4.0 — 2018-05-25
- 2.3.1 — 2018-05-24
- 2.3.0 — 2018-05-23
- 2.2.0 — 2018-05-23
- 2.1.0 — 2018-05-23
- 2.0.2 — 2018-05-23
- 2.0.1 — 2018-05-23
- … 23 more at https://npm.io/package/typed-mysql/versions

## README

# `typed-mysql`

Uses `schema-decorator` to ensure the type-correctness of your MySQL queries.

### Installation

`npm install --save typed-mysql`

### Usage

```
import {Database} from "typed-mysql";
import * as sd from "schema-decorator";

class User {
    @sd.assert(sd.naturalNumber())
    id : number = 0;
    @sd.assert(sd.string())
    username : string = "";
}

async function main () {
    const db = new PooledDatabase({
        host     : Configuration.MysqlHost(),
        database : Configuration.MysqlDatabase(),
        charset  : Configuration.MysqlCharset(),
        user     : Configuration.MysqlUser(),
        password : Configuration.MysqlPassword(),
    });

    const user = await db.selectZeroOrOne(
        User,
        `
            SELECT
                id, username
            FROM
                user
            WHERE
                id = :id
        `,
        {
            id : id,
        }
    );
    console.log(user.id, user.username);
}
main()
    .catch((err) => {
        console.error(`Error in main()`, err);
        process.exit(1);
    });
```

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