From 577ed9240b7df79b1cbbda2558c53018b1026e12 Mon Sep 17 00:00:00 2001 From: Christophe Wagner Date: Sun, 23 Nov 2014 13:15:34 +0100 Subject: [PATCH] Only load models if modelsPath is set --- src/index.coffee | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/index.coffee b/src/index.coffee index f293ffd..c341964 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -98,19 +98,20 @@ class Admin self _readModels: (path, done)-> - debug 'Reading models at %s, from %s', path, process.cwd() - fs.readdir path, (err, files)-> - debug 'Got the following model files:', files - for f in files - require "#{path}/#{f}" - - models = {} - for modelName, model of mongoose.models - models[model.collection.name] = model - debug 'Models: obj', Object.keys(models) - debug 'Models: mongoose', Object.keys(mongoose.models) - - return done(null, models) + if path + debug 'Reading models at %s, from %s', path, process.cwd() + fs.readdir path, (err, files)-> + debug 'Got the following model files:', files + for f in files + require "#{path}/#{f}" + + models = {} + for modelName, model of mongoose.models + models[model.collection.name] = model + debug 'Models: obj', Object.keys(models) + debug 'Models: mongoose', Object.keys(mongoose.models) + + return done(null, models) getModelDetails: (vModel)=>