loopback/node_modules/data-source/lib/data-source.js

40 lines
835 B
JavaScript
Raw Normal View History

2013-04-18 00:43:00 +00:00
/**
* Expose `DataSource`.
*/
module.exports = DataSource;
/**
* Module dependencies.
*/
var AsteroidModule = require('asteroid-module')
, Schema = require('jugglingdb').Schema
, debug = require('debug')('connection')
, util = require('util')
, inherits = util.inherits
, assert = require('assert');
/**
* Create a new `DataSource` with the given `options`.
*
* @param {Object} options
* @return {DataSource}
*/
function DataSource(options) {
AsteroidModule.apply(this, arguments);
this.options = options;
// construct a schema with the available adapter
// or use the default in memory adapter
this.schema = new Schema(this.adapter || require('./memory'), options);
debug('created with options', options);
}
/**
* Inherit from `AsteroidModule`.
*/
inherits(DataSource, AsteroidModule);