不要怂,就是干,撸起袖子干!

Commit 2000687e by Mick Hansen

Add cache to import function

1 parent 32e7f27d
Showing with 5 additions and 1 deletions
...@@ -73,9 +73,13 @@ module.exports = (function() { ...@@ -73,9 +73,13 @@ module.exports = (function() {
return factory return factory
} }
var importCache = {};
Sequelize.prototype.import = function(path) { Sequelize.prototype.import = function(path) {
if (!importCache[path]) {
var defineCall = require(path) var defineCall = require(path)
return defineCall(this, DataTypes) importCache[path] = defineCall(this, DataTypes)
}
return importCache[path];
} }
Sequelize.prototype.migrate = function(options) { Sequelize.prototype.migrate = function(options) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!