ES6 generator-based MongoDB ODM. It rocks.


Awesome ES6 generator-based MongoDB ODM for Node.js v4.x (or newer). Just take a look on its pretty models and beautiful API. Uses official mongodb driver under the hood.

  • Based on ES6 generators, which means no callbacks
  • Established API you've already used to
  • Hooks (before:save, around:create, after:remove, etc)
  • Very simple and easy-to-understand implementation
  • Fully covered by tests
  • Using this module results in a beautiful code
$ npm install mongorito --save

Note: In order for the following examples to work, you need to use co to run generators.

const Mongorito = require('mongorito');
const Model = Mongorito.Model;
// connect to localhost/blog 
yield Mongorito.connect('localhost/blog');
// define model 
class Post extends Model {
// create and save new Post document 
let post = new Post({
    title: 'Node.js with --harmony rocks!',
    body: 'Long post body',
    author: {
        name: 'John Doe'
// update document 
post.set('title', 'Post got a new title!');
post.set('', 'Doe John');
// find posts where body equals "Long post body" 
let posts = yield Post.where('body', 'Long post body').find();
// find posts where author's name equals "John Doe" 
posts = yield Post.where('', 'John Doe').find();
// Bonus: find posts where title starts with "Node" 
posts = yield Post.where('title', /^node/i).find();

Check out Getting Started guide on There are more guides available to learn more.

$ npm test

Mongorito is released under the MIT License.