New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mongorito

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongorito

ES6 generator-based MongoDB ODM. It rocks.

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
104
decreased by-18.11%
Maintainers
1
Weekly downloads
 
Created
Source

Mongorito Circle CI

Awesome ES6 generator-based MongoDB ODM for Node.js v0.11.x (or newer) and io.js. 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
  • 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 or io.js installed (or newer). Run node with --harmony option (not applicable to io.js):

node --harmony script.js

Note: In order for the following examples to work, you need use something like co to run generators. Another note: If you want to use ES6 classes (like in the following examples), use babel. If not, there is an alternative API left from previous versions of Mongorito.

Overview

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

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


// define model
class Post extends Model {
	
}


// 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

Circle CI

To execute tests run:

npm test

License

Mongorito is released under the MIT License.

Keywords

FAQs

Package last updated on 10 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc