# fastify-mongojs

> Fastify plugin for [mongojs](https://github.com/mafintosh/mongojs)

Latest version **0.1.0** (published 2018-08-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install fastify-mongojs
pnpm add fastify-mongojs
yarn add fastify-mongojs
bun add fastify-mongojs
```

## 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 | 2018-08-20 |
| First published | 2018-08-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ákos Kovács |
| Maintainers | lependu |
| Keywords | fastify, mongojs, fastify-plugin, mongodb |

## Links

- npm: https://www.npmjs.com/package/fastify-mongojs
- Repository: https://github.com/lependu/fastify-mongojs
- Homepage: https://github.com/lependu/fastify-mongojs#readme
- Issues: https://github.com/lependu/fastify-mongojs/issues
- npm.io page: https://npm.io/package/fastify-mongojs

## Dependencies (3)

- [fastify](https://npm.io/package/fastify.md) ^1.9.0
- [mongojs](https://npm.io/package/mongojs.md) ^2.6.0
- [fastify-plugin](https://npm.io/package/fastify-plugin.md) ^1.2.0

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 0.1.0 (latest) — 2018-08-20

## README

# fastify-mongojs

Simple wrapper around [mongojs](https://github.com/mafintosh/mongojs) to share common connection pool across [Fastify](https://github.com/fastify/fastify) server. This project is **experimental** if you need something stable, take a look at [fastify-mongodb](https://github.com/fastify/fastify-mongodb)  

[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
[![Build Status](https://travis-ci.org/lependu/fastify-mongojs.svg?branch=master)](https://travis-ci.org/lependu/fastify-mongojs)
[![Known Vulnerabilities](https://snyk.io/test/github/lependu/fastify-mongojs/badge.svg)](https://snyk.io/test/github/lependu/fastify-mongojs)
[![Coverage Status](https://coveralls.io/repos/github/lependu/fastify-mongojs/badge.svg?branch=master)](https://coveralls.io/github/lependu/fastify-mongojs?branch=master)

## Install
```
$ npm i --save fastify-mongojs 
```

## Example
```js
  const Fastify = require('fastify')
  const fastifyMongojs = require('fastify-mongojs')
  
  const fastify = Fastify()

  fastify.register(fastifyMongojs, { 
    name: 'myMongo',
    url: 'myDb',
    collections: ['awesome_collection']
  })

  fastify.get('/', function(req, reply) => {
    // You can reach the db connection with fastify.myMongo
  })

  fastify.listen(3000, err => {
    if (err) throw err
  })  
```

## Reference
name | type | required | default 
-----| :------: | :----------: |---------
**`name`** | `{String}` | :x: | `'mongo'`  
**`url`** | `{String}` | :heavy_check_mark: |   
**`collections`** | `{Array}` | :x: | `[]`   
  
The only plugin specific option is `name` which makes possible to share multiple connection pools across the server instance.
The `url` and `collections` options will be passed to mongojs separately, all other options will be passed to the mongojs instance as well.
For more information about the avaiable options please see [mongojs](https://github.com/mafintosh/mongojs).  
  
## Caveats
Due the recent changes in [mongodb](https://github.com/mongodb/node-mongodb-native) if you pass mongodb connection to mongojs it will fail.
There is a [PR](https://github.com/mafintosh/mongojs/pull/353) in place which needs to be published first, to imlement this feature.  
  
## License
Licensed under [MIT](./LICENSE).

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