loopback/node_modules/store/lib/store.js

40 lines
941 B
JavaScript
Raw Normal View History

/**
* Expose `Store`.
*/
module.exports = Store;
/**
* Module dependencies.
*/
var AsteroidModule = require('asteroid-module')
, Schema = require('jugglingdb').Schema
, debug = require('debug')('store')
, util = require('util')
, inherits = util.inherits
, assert = require('assert');
/**
* Create a new `Store` with the given `options`.
*
* @param {Object} options
* @return {Store}
*/
function Store(options) {
AsteroidModule.apply(this, arguments);
// throw an error if args are not supplied
// assert(typeof options === 'object', 'Store requires an options object');
this.options = options;
debug('created with options', options);
var dependencies = this.dependencies;
var connection = (dependencies && dependencies.connection) || {};
var adapter = this.adapter = (connection && connection.adapter) || require('./memory');
this.schema = new Schema(adapter, connection.options);
}