# app-context-mongodb

> MongoDB initializer for app-context

Latest version **1.0.0** (published 2015-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install app-context-mongodb
pnpm add app-context-mongodb
yarn add app-context-mongodb
bun add app-context-mongodb
```

## 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.0 |
| Published | 2015-09-09 |
| First published | 2015-09-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Matt Insler |
| Maintainers | mattinsler |
| Keywords | app-context, mongodb |

## Links

- npm: https://www.npmjs.com/package/app-context-mongodb
- Repository: https://github.com/app-context/app-context-mongodb
- Issues: https://github.com/app-context/app-context-mongodb/issues
- npm.io page: https://npm.io/package/app-context-mongodb

## Dependencies (2)

- [mongodb](https://npm.io/package/mongodb.md) 2.0.42
- [@mattinsler/app-context-create-connections](https://npm.io/package/@mattinsler/app-context-create-connections.md) 0.0.1

## 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

- 1.0.0 (latest) — 2015-09-09

## README

# app-context-mongodb

[MongoDB](http://mongodb.github.io/node-mongodb-native/2.0/api/) initializer for [app-context](http://app-contextjs.com)

## Usage

This initializer can be auto-installed by using it in your context file.

This initializer will attach the configured connections to `APP.mongodb`.

```javascript
module.exports = function() {
  this.runlevel('connected')
    // attach a connection to APP.mongodb - use the value at APP.config.mongodb as the connection string
    .use('mongodb', '$mongodb')

    // attach a connection to APP.mongodb
    .use('mongodb', 'mongodb://localhost/foobar')

    // create 2 connections and attach them as an object to APP.mongodb
    // this will create APP.mongodb.users and APP.mongodb.data
    .use('mongodb', {
      users: '$mongodb.users',
      data: '$mongodb.data'
    })

    // you can also pass options to each connection
    // (from http://mongodb.github.io/node-mongodb-native/2.0/api/MongoClient.html#.connect)
    .use('mongodb', {
      users: {url: '$mongodb.users', db: {
        wtimeout: 2000,
        authSource: 'other-db'
      }},
      data: {url: 'mongodb://localhost/data', server: {
        reconnectTries: 2,
        reconnectInterval: 500
      }}
    })
};
```

## Connection Strings

Connection string formats and options are available in the [mongodb driver docs](http://docs.mongodb.org/manual/reference/connection-string/).

## Connection Configurations

Each connection can be configured with either a connection string (like `mongodb://localhost/foobar`) or
with an object. The object will be passed through to `MongoClient.connect` and can consist of any options
from the [mongodb driver](http://mongodb.github.io/node-mongodb-native/2.0/api/MongoClient.html#.connect). There is a special `url` option that this initializer requires.

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