Skip to content

Commit 987f29e

Browse files
committed
Merge pull request #2679 from SubuIBM/newRef
Make the app instance available to connectors Close #2679
2 parents ca21243 + 40f0690 commit 987f29e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/application.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ app.dataSource = function(name, config) {
236236
this.dataSources[name] =
237237
this.dataSources[classify(name)] =
238238
this.dataSources[camelize(name)] = ds;
239+
ds.app = this;
239240
return ds;
240241
} catch (err) {
241242
if (err.message) {

test/app.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,12 @@ describe('app', function() {
812812
app.dataSource('bad-ds', { connector: 'throwing' });
813813
}).to.throw(/bad-ds.*throwing/);
814814
});
815+
816+
it('adds app reference to the data source object', function() {
817+
app.dataSource('ds', { connector: 'memory' });
818+
expect(app.datasources.ds.app).to.not.equal(undefined);
819+
expect(app.datasources.ds.app).to.equal(app);
820+
});
815821
});
816822

817823
describe.onServer('listen()', function() {

0 commit comments

Comments
 (0)