monk

The wise MongoDB API

MIT 67 个版本
安装
npm install monk
yarn add monk
pnpm add monk
bun add monk
README

Monk


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

build status codecov

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

版本列表
7.3.4 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
6.0.1 2017-06-22
6.0.0 2017-06-04
5.0.2 2017-05-22
5.0.1 2017-05-21
5.0.0 2017-05-21
4.1.0 2017-05-20
4.0.0 2017-02-13
3.1.4 2017-01-30
3.1.3 2016-10-12
3.1.2 2016-08-22
3.1.1 2016-07-29
3.1.0 2016-07-22
3.0.7 2016-07-14
3.0.6 2016-07-11
3.0.5 2016-07-11
3.0.4 2016-07-07
3.0.3 2016-07-06
3.0.2 2016-07-06
3.0.1 2016-07-06
3.0.0 2016-07-06
2.1.0 2016-06-25
2.0.1 2016-06-24
2.0.0 2016-06-23
1.0.1 2015-03-25
1.0.0 2015-02-28
0.9.1 2014-11-16
0.9.0 2014-05-09
0.8.1 2014-03-01
0.8.0 2014-03-01
0.7.1 2013-03-03
0.7.0 2012-10-30
0.6.0 2012-10-29
0.5.0 2012-10-03
0.4.0 2012-10-03
0.3.0 2012-09-07
0.2.1 2012-07-15
0.2.0 2012-07-15
0.1.15 2012-07-15
0.1.14 2012-07-09
0.1.13 2012-05-28
0.1.12 2012-05-25
0.1.11 2012-05-22
0.1.10 2012-05-21
0.1.9 2012-05-16
0.1.8 2012-05-13
0.1.7 2012-05-08
0.1.6 2012-05-07
0.1.5 2012-05-06
0.1.4 2012-05-06
0.1.3 2012-05-03
0.1.2 2012-05-03
0.1.0 2012-04-23