# monk

> The wise MongoDB API

Latest version **7.3.4** (published 2021-04-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install monk
pnpm add monk
yarn add monk
bun add monk
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 7.3.4 |
| Published | 2021-04-15 |
| First published | 2012-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 46.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1827 |
| Maintainers | rauchg, tootallnate, mathieudutour |
| Keywords | monk, mongodb, mongo, driver |

## Links

- npm: https://www.npmjs.com/package/monk
- Repository: https://github.com/Automattic/monk
- Homepage: https://github.com/Automattic/monk#readme
- Issues: https://github.com/Automattic/monk/issues
- npm.io page: https://npm.io/package/monk

## Dependencies (10)

- [debug](https://npm.io/package/debug.md) *
- [mongodb](https://npm.io/package/mongodb.md) ^3.2.3
- [object-assign](https://npm.io/package/object-assign.md) ^4.1.1
- [@types/mongodb](https://npm.io/package/@types/mongodb.md) ^3.5.25
- [monk-middleware-query](https://npm.io/package/monk-middleware-query.md) ^0.2.0
- [monk-middleware-fields](https://npm.io/package/monk-middleware-fields.md) ^0.2.0
- [monk-middleware-options](https://npm.io/package/monk-middleware-options.md) ^0.2.1
- [monk-middleware-cast-ids](https://npm.io/package/monk-middleware-cast-ids.md) ^0.2.1
- [monk-middleware-handle-callback](https://npm.io/package/monk-middleware-handle-callback.md) ^0.2.0
- [monk-middleware-wait-for-connection](https://npm.io/package/monk-middleware-wait-for-connection.md) ^0.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

- 7.3.4 (latest) — 2021-04-15
- 7.3.3 — 2021-01-27
- 7.3.2 — 2020-08-31
- 7.3.1 — 2020-07-30
- 7.3.0 — 2020-05-12
- 7.2.0 — 2020-04-16
- 7.1.2 — 2020-01-06
- 7.1.1 — 2019-10-11
- 7.1.0 — 2019-09-30
- 7.0.0 — 2019-05-13
- 6.0.6 — 2018-05-10
- 6.0.5 — 2017-10-07
- 6.0.4 — 2017-09-11
- 6.0.3 — 2017-07-31
- 6.0.2 — 2017-07-31
- … 52 more at https://npm.io/package/monk/versions

## README

<h1 align="center">Monk</h1>

<div align="center">
  <img src="https://avatars2.githubusercontent.com/u/28830676?v=3&s=200" />
</div>
<br />
<div align="center">
  <strong>A tiny layer that provides simple yet substantial usability
improvements for MongoDB usage within Node.JS.</strong>
</div>
<br />

[![build status](https://secure.travis-ci.org/Automattic/monk.svg?branch=master)](https://secure.travis-ci.org/Automattic/monk)
[![codecov](https://codecov.io/gh/Automattic/monk/branch/master/graph/badge.svg)](https://codecov.io/gh/Automattic/monk)
[![Join the chat at https://gitter.im/Automattic/monk](https://badges.gitter.im/Automattic/monk.svg)](https://gitter.im/Automattic/monk?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

*note*: monk 2.x drop the support for node < 0.12. If you are still using an earlier version, stick to monk 1.x

```js
const db = require('monk')('localhost/mydb')
// or
// const db = require('monk')('user:pass@localhost:port/mydb')

const users = db.get('users')

users.index('name last')
users.insert({ name: 'Tobi', bigdata: {} })
users.find({ name: 'Loki' }, '-bigdata').then(function () {
  // exclude bigdata field
})
users.find({}, {sort: {name: 1}}).then(function () {
  // sorted by name field
})
users.remove({ name: 'Loki' })

db.close()
```

## Features

- Well-designed API signatures
- Easy connections / configuration
- Command buffering. You can start querying right away
- Promises built-in for all queries. Easy interoperability with modules
- Auto-casting of `_id` in queries
- Allows to set global options or collection-level options for queries. (eg:
  `castIds` is `true` by default for all queries)

## Middlewares

Most of the Monk's features are implemented as [middleware](https://automattic.github.io/monk/docs/middlewares.html).

There are a bunch of third-parties middlewares that add even more functionalities to Monk:
- [monk-middleware-wrap-non-dollar-update](https://github.com/monk-middlewares/monk-middleware-wrap-non-dollar-update)
- [monk-middleware-debug](https://github.com/monk-middlewares/monk-middleware-debug)
- [monk-middleware-dereference](https://github.com/monk-middlewares/monk-middleware-dereference)

*Created an nice middleware? Send a PR to add to the list!*

## How to use

[Documentation](https://Automattic.github.io/monk)

## License

MIT

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