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

Commit 513fec72 by Overlook Motel

Define adds model to sequelize.models

1 parent 80503f1f
Showing with 3 additions and 0 deletions
...@@ -9,6 +9,7 @@ module.exports = (function() { ...@@ -9,6 +9,7 @@ module.exports = (function() {
ModelManager.prototype.addDAO = function(dao) { ModelManager.prototype.addDAO = function(dao) {
this.daos.push(dao) this.daos.push(dao)
this.sequelize.models[dao.name] = dao
return dao return dao
} }
...@@ -17,6 +18,7 @@ module.exports = (function() { ...@@ -17,6 +18,7 @@ module.exports = (function() {
this.daos = this.daos.filter(function(_dao) { this.daos = this.daos.filter(function(_dao) {
return _dao.name != dao.name return _dao.name != dao.name
}) })
delete this.sequelize.models[dao.name]
} }
ModelManager.prototype.getDAO = function(daoName, options) { ModelManager.prototype.getDAO = function(daoName, options) {
......
...@@ -162,6 +162,7 @@ module.exports = (function() { ...@@ -162,6 +162,7 @@ module.exports = (function() {
} catch(err) { } catch(err) {
throw new Error("The dialect " + this.getDialect() + " is not supported.") throw new Error("The dialect " + this.getDialect() + " is not supported.")
} }
this.models = {}
this.modelManager = this.daoFactoryManager = new ModelManager(this) this.modelManager = this.daoFactoryManager = new ModelManager(this)
this.transactionManager = new TransactionManager(this) this.transactionManager = new TransactionManager(this)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!