Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 109 lines (65 sloc) 2.491 kb
3ad4344 @vdemedes update readme formatting
authored
1 # Mongorito [![Circle CI](https://circleci.com/gh/vdemedes/mongorito.svg?style=svg)](https://circleci.com/gh/vdemedes/mongorito)
ad5ddaa @vdemedes Mongorito is dead, long live Mongorito
authored
2
2589a38 @vdemedes mention iojs and babel
authored
3 Awesome ES6 generator-based MongoDB ODM for Node.js v0.11.x (or newer) and io.js.
ad6a2cc @vdemedes more love to Mongorito description
authored
4 Just take a look on its pretty models and beautiful API.
5 Uses [monk](https://github.com/Automattic/monk) under the hood.
ad5ddaa @vdemedes Mongorito is dead, long live Mongorito
authored
6
c0b4069 @vdemedes added npm package stats to Readme
authored
7
3ad4344 @vdemedes update readme formatting
authored
8 ### Features
f55f1d6 @vdemedes hooks
authored
9
10 - Based on ES6 generators, which means **no callbacks**
11 - Common, established API you've already used to
12 - Hooks (before:save, around:create, after:remove, etc)
13 - Very simple and easy-to-understand implementation
14 - Fully covered by tests
15
3ad4344 @vdemedes update readme formatting
authored
16
17 ### Installation
ad5ddaa @vdemedes Mongorito is dead, long live Mongorito
authored
18
19 ```
20 npm install mongorito --save
21 ```
22
2589a38 @vdemedes mention iojs and babel
authored
23 **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):
ad5ddaa @vdemedes Mongorito is dead, long live Mongorito
authored
24
25 ```
2589a38 @vdemedes mention iojs and babel
authored
26 node --harmony script.js
ad5ddaa @vdemedes Mongorito is dead, long live Mongorito
authored
27 ```
28
f0505d8 @vdemedes added Travis CI
authored
29 **Note**: In order for the following examples to work, you need use something like [co](https://github.com/tj/co) to run generators.
2589a38 @vdemedes mention iojs and babel
authored
30 **Another note**: If you want to use ES6 classes (like in the following examples), use [babel](https://github.com/babel/babel). If not, there is an alternative API left from previous versions of Mongorito.
ad5ddaa @vdemedes Mongorito is dead, long live Mongorito
authored
31
3ad4344 @vdemedes update readme formatting
authored
32
33 ### Overview
23ace11 @vdemedes added overview of functionality to readme
authored
34
35 ```javascript
36 var Mongorito = require('mongorito');
37 var Model = Mongorito.Model;
38
39 // connect to localhost/blog
40 Mongorito.connect('localhost/blog');
41
42
43 // define model
f0505d8 @vdemedes added Travis CI
authored
44 class Post extends Model {
29e4ab5 @vdemedes automatically set collection name, if missing
authored
45
f0505d8 @vdemedes added Travis CI
authored
46 }
23ace11 @vdemedes added overview of functionality to readme
authored
47
48
49 // create new Post document
50 var post = new Post({
51 title: 'Node.js with --harmony rocks!',
52 body: 'Long post body',
53 author: {
54 name: 'John Doe'
55 }
56 });
57
58
59 // create
60 yield post.save();
61
62
63 // update document
64 post.set('title', 'Post got a new title!');
65 post.set('author.name', 'Doe John');
66
67
68 // update
69 yield post.save();
70
71
72 // find some posts
73 var posts;
74
75 // find posts where body equals "Long post body"
76 posts = yield Post.where('body', 'Long post body').find();
77
78 // find posts where author's name equals "John Doe"
79 posts = yield Post.where('author.name', 'John Doe').find();
80
81 // Bonus: find posts where title starts with "Node"
82 posts = yield Post.where('title', /^node/i).find();
83
84
85 // disconnect
86 Mongorito.disconnect();
87 ```
88
3ad4344 @vdemedes update readme formatting
authored
89
90 ### Getting Started
ad5ddaa @vdemedes Mongorito is dead, long live Mongorito
authored
91
453e9a6 @vdemedes inserted link to getting started guide in readme
authored
92 Check out [Getting Started](http://mongorito.com/guides/getting-started) guide on [http://mongorito.com](http://mongorito.com).
791f37c @vdemedes added support for multiple databases, fix #6
authored
93
3ad4344 @vdemedes update readme formatting
authored
94
95 ### Tests
ad5ddaa @vdemedes Mongorito is dead, long live Mongorito
authored
96
b6cfe57 @vdemedes add test badge to Tests section
authored
97 [![Circle CI](https://circleci.com/gh/vdemedes/mongorito.svg?style=svg)](https://circleci.com/gh/vdemedes/mongorito)
98
ad5ddaa @vdemedes Mongorito is dead, long live Mongorito
authored
99 To execute tests run:
100
101 ```
102 npm test
103 ```
104
3ad4344 @vdemedes update readme formatting
authored
105
106 ### License
ad5ddaa @vdemedes Mongorito is dead, long live Mongorito
authored
107
5ca2dae @vdemedes removed big license
authored
108 Mongorito is released under the MIT License.
Something went wrong with that request. Please try again.