Giter Site home page Giter Site logo

resourceful-mongo's Introduction

#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

License: Apache 2.0

resourceful-mongo's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  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.