Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here


The wise MongoDB API

Subscribe to updates I use monk

Statistics on monk

Number of watchers on Github 1412
Number of open issues 18
Average time to close an issue 3 months
Main language JavaScript
Average time to merge a PR about 1 month
Open pull requests 19+
Closed pull requests 12+
Last commit over 2 years ago
Repo Created about 8 years ago
Repo Last Updated over 2 years ago
Size 1.06 MB
Organization / Authorautomattic
Latest Releasev6.0.0
Page Updated
Do you use monk? Leave a review!
View open issues (18)
View monk activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating monk for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)


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' })



  • 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)


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




monk open issues Ask a question     (View All Issues)
  • over 3 years Are there any event handlers to deal with the "error-opening" event
  • over 3 years Add mapReduce method
  • almost 4 years collection.ensureIndex deprecated in MongoDB 3.0.0
  • almost 4 years Is there a better way to use child-referencing
  • almost 4 years DSL for building an aggregation pipeline
  • almost 4 years Inserting field with `undefined` value inserts `null` instead of `undefined`
  • almost 4 years wrap non-$ fields in the `update` object in `$set`
  • over 5 years Add findOrCreate method
  • about 6 years cache database connection in module space
  • almost 7 years dereference?
  • almost 7 years Add collection.save
  • over 7 years Allow comma as field separator
  • almost 8 years Default connection string to `localhost`
  • almost 8 years Ensure that callbacks for updates when safe mode is true and a document was actually modified are different from when no document matched
monk open pull requests (View All Pulls)
  • Support $ne for id casting.
  • Update mongoskin to v2
  • Fix repository URL in package.json
  • travis config update
  • Make the sort option behave like fields
  • Add "group" method
  • Update mongoskin to v2.1
  • Replace expect.js with chai and test against newer versions of node
  • Mongodb native driver and mongo skin updated
  • 2.x
  • gitbook documentation
  • auto-generated doc
  • ensureIndex -> createIndexes
  • Add castId option description to documentation
  • Added map reduce
  • return null when findOneAnd... find nothing
  • Use strict mode
  • #214: Some broken MD Links
  • Change links in READMEs
monk questions on Stackoverflow (View All Questions)
  • mpromise/Monk promise never resolves
  • How to Retrieve MongoDb collection Id with Monk
  • MongoDB findAndModify not working with monk
  • Monk not inserting properly?
  • how to use $in in mongo monk
  • MongoDB being interacted with through monk returns differing values upon document removal
  • How to insert a document's nested data with Mongoskin / monk without building object
  • MongoDB, Monk, findAndModify not upserting
  • node js monk update lingers
  • Stop Monk from adding _id to docs
  • Monk in nodejs sometimes returns null on findAndModify
  • monk query inside async loop?
  • Add $hint to query with monk
  • Monk freezing when ID isn't found in MongoDB
  • mongodb aggregation (co-monk) undefined function
  • How to upload video file into monk database using AngularJS?
  • Mongodb + koja + co-monk returning wrong value?
  • Failed to load c++ bson extension, using pure JS version when using monk to access Mongodb
  • How to insert a document with a subdocument array element in MongoDB with Monk
  • How can I know the amount of documents modified by monk?
  • How to do passport.js with monk instead of mongoose?
  • Unable to access a record of a collection of mongo using monk in node.js
  • mongo / monk - not firing promise.done?
  • selecting required fields in mongodb using monk
  • select only two fields in mongodb using monk
  • How to get a list of items from a mongodb collection using monk and node
  • monk vs mongoose for Mongodb
  • Mongodb/Monk 'count' is undefined
  • How to rewrite asynchronous function (node.js, monk)
  • not able to connect to mongodb hosted on remote server using monk
monk list of languages used
monk latest release notes
v6.0.0 v6.0.0
  • Add typescript definition (fix #204)
  • return null when findOneAnd... find nothing (fix #175)
  • remove now uses deleteOne or deleteMany under the hood (fix #178)
  • Add mapReduce method (fix #167)
  • Add geoHaystackSearch method
  • Add geoNear method
  • Add stats method (fix #191)
  • Remove monk specific options used by middleware (fix #203)
  • The only option set globally is castIds. safe is not true by default anymore.
  • Return the cursor in a promise (when using the rawCursor on the find method) so that the entire API has the same return type (a promise)
v5.0.2 v5.0.2
  • Emit event from the manager from the underlying db emits an event (fix #189)
v5.0.1 v5.0.1
  • Fix typo on requesting middlewares
Other projects in JavaScript