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

Commit 2000687e by Mick Hansen

Add cache to import function

1 parent 32e7f27d
Showing with 6 additions and 2 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) {
var defineCall = require(path) if (!importCache[path]) {
return defineCall(this, DataTypes) var defineCall = require(path)
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!