diff --git a/lib/application.js b/lib/application.js index b9facad0..7a3abef5 100644 --- a/lib/application.js +++ b/lib/application.js @@ -390,13 +390,15 @@ function configureModel(ModelCtor, config, app) { var dataSource = config.dataSource; - if(typeof dataSource === 'string') { - dataSource = app.dataSources[dataSource]; - } + if(dataSource) { + if(typeof dataSource === 'string') { + dataSource = app.dataSources[dataSource]; + } - assert(dataSource instanceof DataSource, - ModelCtor.modelName + ' is referencing a dataSource that does not exist: "' + - config.dataSource +'"'); + assert(dataSource instanceof DataSource, + ModelCtor.modelName + ' is referencing a dataSource that does not exist: "' + + config.dataSource +'"'); + } config = extend({}, config); config.dataSource = dataSource; diff --git a/test/app.test.js b/test/app.test.js index 2832a7b3..935019b8 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -69,6 +69,10 @@ describe('app', function() { request(app).get('/colors').expect(200, done); }); }); + + it('should not require dataSource', function() { + app.model('MyTestModel', {}); + }); }); describe('app.model(name, config)', function () {