# @1mill/mongo

> Reuse MongoDB connections between AWS Lambda invocations.

Latest version **0.3.4** (published 2023-09-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @1mill/mongo
pnpm add @1mill/mongo
yarn add @1mill/mongo
bun add @1mill/mongo
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.4 |
| Published | 2023-09-16 |
| First published | 2021-09-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | 1mill |
| Keywords | mongodb, lambda |

## Links

- npm: https://www.npmjs.com/package/@1mill/mongo
- Repository: https://github.com/1mill/mongo
- Homepage: https://github.com/1mill/mongo#readme
- Issues: https://github.com/1mill/mongo/issues
- npm.io page: https://npm.io/package/@1mill/mongo

## Dependencies (1)

- [mongodb](https://npm.io/package/mongodb.md) ^6.1.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
- [@temporal-architect/claude-plugin](https://npm.io/package/@temporal-architect/claude-plugin.md) — 335 weekly downloads

## Recent versions

- 0.3.4 (latest) — 2023-09-16
- 0.3.3 — 2023-09-16
- 0.3.2 — 2023-09-16
- 0.3.1 — 2023-09-16
- 0.3.0 — 2023-09-16
- 0.2.0 — 2023-09-16
- 0.1.0 — 2023-09-16
- 0.0.5 — 2021-12-24
- 0.0.4 — 2021-10-08
- 0.0.3 — 2021-09-30
- 0.0.2 — 2021-09-30
- 0.0.1 — 2021-09-30

## README

# @1mill/mongo

Reuse MongoDB connections between AWS Lambda invocations.

## Getting started

```bash
npm install @1mill/mongo
```

```node
const { Mongo } = require('@1mill/mongo')

const mongo = new Mongo({
  db: 'my-database-name',
  uri: 'mongodb://my-username:my-password@my-mong-host-name:27017/my-database-name',
})

exports.handler = async (cloudevent = {}, ctx = {}) {
  ctx.callbackWaitsForEmptyEventLoop = false

  const { db } = await mongo.connect()

  const collection = db.collection('my-collection-name')
  await collection.createIndex({ something: 1 })
  await collection.insertOne({ something: 'yes' })
}
```

| Name    | Required | Default                    | Notes                                                         |
|---------|----------|----------------------------|---------------------------------------------------------------|
| db      |          | process.env.MILL_MONGO_DB  |                                                               |
| options |          | {}                         | `useNewUrlParser` and `useUnifiedTopology` enabled by default |
| uri     | yes      | process.env.MILL_MONGO_URI |                                                               |

## Deploying

1. Commit changes
1. Run `npm version (major|minor|patch)`
1. Run `git push`
1. Run `npm run deploy`

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