Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Automattic/monk
The wise MongoDB API
https://github.com/Automattic/monk
Last synced: 3 months ago
JSON representation
The wise MongoDB API
- Host: GitHub
- URL: https://github.com/Automattic/monk
- Owner: Automattic
- License: mit
- Created: 2012-04-20T14:42:48.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2023-03-13T18:02:49.000Z (almost 2 years ago)
- Last Synced: 2024-10-29T15:34:31.764Z (4 months ago)
- Language: JavaScript
- Size: 1.2 MB
- Stars: 1,846
- Watchers: 135
- Forks: 182
- Open Issues: 48
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
Monk
![]()
A tiny layer that provides simple yet substantial usability
improvements for MongoDB usage within Node.JS.
[](https://secure.travis-ci.org/Automattic/monk)
[](https://codecov.io/gh/Automattic/monk)
[](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