No description, website, or topics provided.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
lib
test
.gitignore
.npmignore
monglow.js
package.json
readme.md

readme.md

Monglow

A MongoDB ODM for Node.js. Monglow focuses on dead simple model declaration, allowing a schema less definition, and providing easy relationships.

I couldn't find one that did these things, so here I am.

Init

var Monglow = require("monglow")
Monglow.connect("mongo://localhost/monglow") // leaving blank results in localhost/monglow_test

I recommend doing the connect in an initializer so you only have to call it once.

A Model

var Post = Monglow.model('posts');

Done. Seriously. But you can do more if you want.

Like add a static finder.

Post.find_by_custom_stuff = function(callback) {
  this.find({stuff: "custom"}, callback);
}

Then you can use the model.

var post = new Post({name: "Jonathan"});
post.save();
post.remove();
Post.create({name: "not Jonathan"});

Post.find(function(err, posts) {
  // do stuff with posts
  posts[0].name = "Spies";
  posts[0].save();

  posts[0].save({name: "not Spies"});
});

Relationships

var Author = Monglow.model("authors");

Post.references_many('authors');