Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

resourceful mongodb engine

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 README.md
Octocat-spinner-32 package.json
README.md

resourceful-mongo Build Status

A MongoDB engine for resourceful, a datamapper part of the flatiron project.

Credits

Ryan Fitzgerald, Follow @TheRyanFitz on Twitter.

Warning

This project is in a very early stage, with limited functionality. Don't use in production.

Example

  var resourceful = require('resourceful-mongo');

  //Define the resources
  var Person = resourceful.define('person', function () {

    this.use('mongodb', {
      uri: "mongodb://localhost/databaseName", // required - the mongo URI of the database
      collection: "people", // required - the name of the collection
      safe: true // optional - run the driver in safe mode to ensure that the update succeeded. Defaults to false
    });

    this.string('name');
    this.number('age');
  });

  var Flower = resourceful.define('flower', function () {

    this.use('mongodb', {

      //The mongo URI can also be defined piecemeal
      host: "localhost", 
      database: "databaseName",
      collection: "flowers",
      safe: true 
    });

    this.string('color');
    this.number('petals');
  });

  //Open the mongodb connection
  resourceful.use('mongodb', {
    uri: "mongodb://localhost/databaseName", // required - the connection to be opened
    onConnect: function (err) { // required - the callback upon opening the database connection
        if (!err) app.start(8000);
    }
  });

Installation

Installing npm (node package manager)

  $ curl http://npmjs.org/install.sh | sh

Installing resourceful

  $ [sudo] npm install resourceful-mongo

Tests

All tests are written with mocha and should be run with npm:

  $ npm test

Author: Ryan Fitzgerald

License: Apache 2.0

Something went wrong with that request. Please try again.