# @rough/rx-mysql

> A simple RxJS wrapper around mysql lib

Latest version **1.0.5** (published 2018-11-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rough/rx-mysql
pnpm add @rough/rx-mysql
yarn add @rough/rx-mysql
bun add @rough/rx-mysql
```

## 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.0.5 |
| Published | 2018-11-01 |
| First published | 2018-11-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Igor Ostapenko |
| Maintainers | ihoro |
| Keywords | sql, mysql, reactive, rx, rxjs, observable |

## Links

- npm: https://www.npmjs.com/package/@rough/rx-mysql
- Repository: https://github.com/ihoro/rough-rx-mysql
- Homepage: https://github.com/ihoro/rough-rx-mysql#readme
- Issues: https://github.com/ihoro/rough-rx-mysql/issues
- npm.io page: https://npm.io/package/@rough/rx-mysql

## Dependencies (1)

- [rxjs](https://npm.io/package/rxjs.md) ^6.3.3

## Recent versions

- 1.0.5 (latest) — 2018-11-01
- 1.0.4 — 2018-11-01
- 1.0.3 — 2018-11-01
- 1.0.2 — 2018-11-01
- 1.0.1 — 2018-11-01
- 1.0.0 — 2018-11-01

## README

# Rx MySQL

[![Build Status](https://travis-ci.com/ihoro/rough-rx-mysql.svg?branch=master)](https://travis-ci.com/ihoro/rough-rx-mysql)
[![npm version](https://badge.fury.io/js/%40rough%2Frx-mysql.svg)](https://badge.fury.io/js/%40rough%2Frx-mysql)

Rough implementation of [rxified](https://npmjs.com/rxjs) wrapper of [mysql](https://npmjs.com/mysql) lib.

## Getting started

Installation
```
$ npm i mysql @rough/rx-mysql
```

A simple query
```js
const { finalize } = require('rxjs/operators');
const { createPool } = require('mysql');
const RxMySQL = require('@rough/rx-mysql');

const pool = createPool({
  host: 'localhost',
  user: 'root',
  password: 'root',
  database: 'myproject'
});

const rxsql = new RxMySQL(pool);

rxsql
  .query('select * from users')
  .pipe(finalize(_ => pool.end()))
  .subscribe(result => console.log(result));
```

A simple transaction
```js
rxsql
  .transaction(
    (rxsql, prevResult) => rxsql.query('select * from users where id = ? for update', 42),
    (rxsql, prevResult) => rxsql.query('delete from deals where user_scope_id = ?', prevResult[0].user_scope_id),
    (rxsql, prevResult) => rxsql.query('delete from inventory where user_id = ?', 42),
  )
  .pipe(finalize(_ => pool.end()))
  .subscribe(result => console.log(result));
```

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