Skip to content
The wise MongoDB API
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets add favicon May 21, 2017
docs
lib fix Nov 1, 2017
middlewares break out of the promise chain for a callback Sep 14, 2017
test
.editorconfig
.eslintrc add createIndex method May 20, 2017
.gitignore start documentation Jun 29, 2016
.travis.yml
CHANGELOG.md version 6.0.6 May 10, 2018
LICENCE.md
Makefile move callback and wait handling to middlewares May 21, 2017
README.md
SUMMARY.md
book.json fix book.json May 21, 2017
index.d.ts missed distinct Dec 28, 2018
package.json version 6.0.6 May 10, 2018

README.md

Monk


A tiny layer that provides simple yet substantial usability improvements for MongoDB usage within Node.JS.

build status codecov Join the chat at https://gitter.im/Automattic/monk

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

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.

There are a bunch of third-parties middlewares that add even more functionalities to Monk:

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

How to use

Documentation

License

MIT

You can’t perform that action at this time.