jsbin/lib/store.js
Aron Carroll 20a7ea5b3c Add support for saving a bin revision
Support is still very basic but a revision can be created, streaming
is not yet supported as we are waiting on sessions.
2012-04-22 19:00:07 +01:00

29 lines
628 B
JavaScript

function Store(options) {
var Adapter = require('./db/' + options.adapter);
this.adapter = new Adapter(options[options.adapter]);
}
// Methods that should be supported by adaptors.
var methods = [
'connect',
'disconnect',
'setBin',
'setBinPanel',
'getBin',
'getLatestBin',
'getBinsByOwner',
'generateBinId'
];
// Proxy the methods through the store.
methods.forEach(function (method) {
Store.prototype[method] = function () {
this.adapter[method].apply(this.adapter, arguments);
};
});
module.exports = function createStore(options) {
return new Store(options);
};
module.exports.Store = Store;