Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.
/ mongorito Public archive
forked from vadimdemedes/mongorito

ES6 generator-based MongoDB ODM for Node.js. It rocks.

Notifications You must be signed in to change notification settings

waigo/mongorito

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mongorito

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

NPM stats

Features

  • Based on ES6 generators, which means no callbacks
  • Common, 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

Installation

npm install mongorito --save

Warning: You should have Node.js v0.11.x installed (or newer). Run node with --harmony option:

node --harmony something.js

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

Overview

var Mongorito = require('mongorito');
var Model = Mongorito.Model;

// connect to localhost/blog
Mongorito.connect('localhost/blog');


// define model
var Post = Model.extend({
    collection: 'posts'
});


// create new Post document
var post = new Post({
    title: 'Node.js with --harmony rocks!',
    body: 'Long post body',
    author: {
        name: 'John Doe'
    }
});


// create
yield post.save();


// update document
post.set('title', 'Post got a new title!');
post.set('author.name', 'Doe John');


// update
yield post.save();


// find some posts
var posts;

// find posts where body equals "Long post body"
posts = yield Post.where('body', 'Long post body').find();

// find posts where author's name equals "John Doe"
posts = yield Post.where('author.name', 'John Doe').find();

// Bonus: find posts where title starts with "Node"
posts = yield Post.where('title', /^node/i).find();


// disconnect
Mongorito.disconnect();

Getting Started

Check out Getting Started guide on http://mongorito.com.

Tests

To execute tests run:

npm test

License

Mongorito is released under the MIT License.

About

ES6 generator-based MongoDB ODM for Node.js. It rocks.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%