# @psibean/typeorm-provider

> A TypeORM based provider for discord-akairo.

Latest version **0.0.10** (published 2021-01-12) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @psibean/typeorm-provider
pnpm add @psibean/typeorm-provider
yarn add @psibean/typeorm-provider
bun add @psibean/typeorm-provider
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.10 |
| Published | 2021-01-12 |
| First published | 2021-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Psi |
| Maintainers | psibean |
| Keywords | discord, discord-js, discord.js, discord-akairo, typeorm |

## Links

- npm: https://www.npmjs.com/package/@psibean/typeorm-provider
- Repository: https://github.com/psibean/typeorm-provider
- Homepage: https://github.com/psibean/typeorm-provider#readme
- Issues: https://github.com/psibean/typeorm-provider/issues
- npm.io page: https://npm.io/package/@psibean/typeorm-provider

## Alternatives

- [@libsql/sqlite3](https://npm.io/package/@libsql/sqlite3.md) — 39.8K weekly downloads
- [@fortemi/core](https://npm.io/package/@fortemi/core.md) — 461 weekly downloads
- [cdb-converter](https://npm.io/package/cdb-converter.md) — 341 weekly downloads
- [@uplo/adapter-prisma](https://npm.io/package/@uplo/adapter-prisma.md) — 75 weekly downloads
- [typeorm-aios](https://npm.io/package/typeorm-aios.md) — 30 weekly downloads

## Recent versions

- 0.0.10 (latest) — 2021-01-12
- 0.0.9 — 2021-01-11
- 0.0.8 — 2021-01-04
- 0.0.7 — 2021-01-02
- 0.0.6 — 2021-01-02
- 0.0.5 — 2021-01-02
- 0.0.4 — 2021-01-02
- 0.0.3 — 2021-01-02
- 0.0.2 — 2021-01-02
- 0.0.1 — 2021-01-02

## README

# TypeORMProvider

Note: I've shifted to my [PrismaProvider](https://github.com/psibean/prisma-provider)

I'm using [TypeORM](https://github.com/typeorm/typeorm) with [discord.js](https://github.com/discordjs/discord.js) and [discord-akairo](https://github.com/discord-akairo), since discord-akairo does not yet natively support a TypeORM provider, I made this one! Nothing special, all I did was copy the SequelizeProvider and update it to use a TypeORM Repository instead.

Feel free to use this and make changes, happy to accept pull requests if I've messed something up or overlooked / misunderstood something.

## Installation
Ensure you have [TypeORM](https://github.com/typeorm/typeorm), [discord.js](https://github.com/discordjs/discord.js), and [discord-akairo](https://github.com/discord-akairo) already installed.

```
npm install @psibean/typeorm-provider
```

## Usage

```
import { TypeORMProvider } from '@psibean/typeorm-provider';
```
```
const { TypeORMProvider } = require('@psibean/typeorm-provider');
```
```
provider = new 
            TypeORMProvider(
              connection.get(connectionName).getRepository(Entity), 
              { idColumn: "id", 
                dataColumn: "jsonColumnName" 
            });
```

One other difference between this provider and the other providers is set, which can take a defaultData value for when it has to create a new record:

```
provider.set(id, key, value, defaultData = { "one": true, "two": "someValue" });
```

If there is no record for the provided id, then a new record will be created that looks like:
```
{ "one": true, "two": "someValue", [key]: value } 
```

If the provided key matches one of the keys in the defaultData the passed value will overwrite the default.

It otherwise works the same as the other providers, the only difference is instead of taking the actual model / entity, it takes the repository instead.

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