Giter VIP home page Giter VIP logo

mongorito's Introduction

Mongorito Build Status

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 monk under the hood.




Features

  • 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

Installation

$ npm install mongorito --save

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

Usage

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

// connect to localhost/blog
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'
    }
});

yield post.save();


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

yield post.save();

// 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('author.name', 'John Doe').find();

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

API

Check out Getting Started guide on http://mongorito.com. There are more guides available to learn more.

Tests

Build Status

$ make test

License

Mongorito is released under the MIT License.

mongorito's People

Contributors

olistic avatar

Watchers

James Cloos avatar Paul Ryan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.