# knex-multiconnect

> A library to manage multiple knex instances for integration with read replicas and master database instances

Latest version **0.1.0** (published 2017-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install knex-multiconnect
pnpm add knex-multiconnect
yarn add knex-multiconnect
bun add knex-multiconnect
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2017-09-23 |
| First published | 2017-09-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Rich Dillon |
| Maintainers | richraid21 |

## Links

- npm: https://www.npmjs.com/package/knex-multiconnect
- Repository: https://github.com/richraid21/knex-multiconnect
- Homepage: https://github.com/richraid21/knex-multiconnect#readme
- Issues: https://github.com/richraid21/knex-multiconnect/issues
- npm.io page: https://npm.io/package/knex-multiconnect

## Recent versions

- 0.1.0 (latest) — 2017-09-23

## README

# Knex MultiConnect

## Introduction

> The small library is designed to help manage multiple connection pools when using the [Knex](https://github.com/tgriesser/knex) SQL builder library. Most often, the need for multiple connections arises when using a database that contains slaves that act as read-only replicas. With this library, you can register multiple Knex instances that are associated with a type: read or write. When you need to make a query, you can select to use a connection that is marked as either read or write, depending on the type of query you intend to execute. 

## Usage

> Using the library simply requires you to create a Knex instance, register it with the library, then call whichever type of connection you need.

```javascript
  const KnexManager = require('knex-multiconnect').default

  const KM = new KnexManager();

  KM.registerInstance('read', knex) //knex is an existing knex instance, not shown to save space
  
  KM.read().knex('users').select().then((res) => {
    console.log(res)
  })

  KM.destroyAllInstances()
```

## Installation

> Grab and go!    

```console
npm install -S knex-multiconnect
#or
yarn add knex-multiconnect
```

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