Skip to content

Commit

Permalink
lib/registry: fix findModel for model ctor
Browse files Browse the repository at this point in the history
Fix `registry.findModel(arg)` to support the case when `arg` is already
a model constructor.
  • Loading branch information
Miroslav Bajtoš committed Nov 9, 2015
1 parent e633617 commit 36cd5a7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Registry.prototype._defineRemoteMethods = function(ModelCtor, methods) {
* @header loopback.findModel(modelName)
*/
Registry.prototype.findModel = function(modelName) {
if (typeof modelType === 'function') return modelName;
if (typeof modelName === 'function') return modelName;
return this.modelBuilder.models[modelName];
};

Expand Down
1 change: 1 addition & 0 deletions test/loopback.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ describe('loopback', function() {
assert(loopback.getModel('MyModel') === MyModel);
assert(loopback.getModel('MyCustomModel') === MyCustomModel);
assert(loopback.findModel('Invalid') === undefined);
assert(loopback.getModel(MyModel) === MyModel);
});
it('should be able to get model by type', function() {
var MyModel = loopback.createModel('MyModel', {}, {
Expand Down

0 comments on commit 36cd5a7

Please sign in to comment.