Skip to content

qualiancy/seed-mongodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Seed MongoDB Build Status

This module provides a storage engine for Seed that allows datasets to be stored in MongoDB.

Installation

Module is available through npm. To use it in your project you must also have seed installed, as it is not provided as package.json requirement.

  npm install seed seed-mongodb

What is Seed?

Seed, which stands for storage-agnostic, event emitting datasets, is a library of components that provide a common API for working with data, no matter the source. These compoents are Hash, Model, Graph, and Schema. MongoDB can be one the many sources used in the construction eventful, data-centric applications.

Visit the Seed project page to learn more.

Usage

This storage engine can be used for both models and collections.

var Seed = require('seed')
  , MongoStore = require('seed-mongodb')
  , store = new MongoStore({
        db: 'hitchhikersguide'
      , host: 'localhost'
      , port: 27017
    });

var Person = Seed.Model.extend('person', {
  store: store
});

var arthur = new Person({
    id: 'arthur'
  , name: 'Arthur Dent'
  , occupation: 'Traveller'
});

arthur.save(function (err) {
  if (err) return console.error(err);
  console.log('Arthur has been saved!');
});

Querying

When fetching from a Graph, the queries are passed directly to the mongo database, and should follow MongoDB's form. For more information, check out Mongo's Guide on Querying and the awesome node-mongo-native topic on queries.

var HitchhikersGuide = Seed.Graph.extend({
    store: store
  , initialize: function () {
      this.define(Person);
    }
});

var myGuide = new HitchhikersGuide();
myGuide.fetch('person', { 'name': 'Arthur Dent' }, function (err) {
  var arthur = self.get('/person/arthur');
});

Tests

Tests are writting in Mocha using the Chai should BDD assertion library. Make sure you have that installed, clone this repo, install dependacies using npm install.

$ make test

You will also need a local installation of MongoDB available on 'localhost:27017' without authentication. Custom test database options are not provided by default.

Getting Help

All issues related to this project should be posted in seed-mongodb GitHub Issues. For all general seed related issues, please visit seed's GitHub Issues. There is also a community forum is available at the Seed Google Group.

Contributors

Interested in contributing? Fork to get started. Contact @logicalparadox if you are interested in being regular contributor.

License

(The MIT License)

Copyright (c) 2012 Jake Luer [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Store your Seed datasets in MongoDB.

Resources

Stars

Watchers

Forks

Packages

No packages published