Skip to content

Consider Decoupling all but Memory Engine #109

DamonOehlman opened this Issue Aug 27, 2012 · 3 comments

2 participants


Hey Guys,

Love the general approach of resourceful, but just wondering why actual storage engines are implemented within the core library? Even though I primarily use CouchDB, it really just does make that much sense (to me) to have a library that handles abstract model definition implement storage adapters within the library itself?

This for me is somewhat reminiscent of earlier versions of winston which included an implementation of the loggly reporter and package dependencies to make it work.

Taking the example in the readme, I'd much rather do something like the following to wire up the storage engine:

var resourceful = require('resourceful'),
    couchStorage = require('resourceful-couchdb');

var Creature = resourceful.define('creature', function () {
  // Specify a storage engine

  // Specify some properties with validation

  // Specify timestamp properties

// Now that the `Creature` prototype is defined
// we can add custom logic to be available on all instances
Creature.prototype.feed = function (food) {

You could additionally support your existing implementation by implementing an engine registry within resourceful, so that some initialization code such as below would result in the readme code working as is:

resourceful.engines.register('couchdb', require('resourceful-couchdb'));

I'd certainly be happy to work on this kind of implementation if you felt that it was a direction that you wanted to take resourceful in.


Marak commented Aug 27, 2012

Yes, that is an artifact from the old design.

We'll be moving towards a broadway based plugin system for resource engines eventually.

No need to build something new. Broadway.use should be able to handle this.

Feel free to start up a fork / pull request.

Marak commented Aug 27, 2012

Seems somewhat relevant:



Good call on using Broadway, re plugins I've written a small experimental library will comment on indexzero/broadway#34.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.