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

Commit ebaec176 by Sascha Depold

check if the passed reference is a DaoFactory

1 parent 1134d01d
Showing with 12 additions and 8 deletions
var Toposort = require('toposort-class')
var Toposort = require('toposort-class')
, DaoFactory = require('./dao-factory')
module.exports = (function() {
var DAOFactoryManager = function(sequelize) {
......@@ -39,18 +40,21 @@ module.exports = (function() {
* before dependents.
*/
DAOFactoryManager.prototype.forEachDAO = function(iterator) {
var daos = {}
var daos = {}
, sorter = new Toposort()
this.daos.forEach(function(dao) {
daos[dao.tableName] = dao
var deps = []
for(var attrName in dao.rawAttributes) {
if(dao.rawAttributes.hasOwnProperty(attrName)) {
if(dao.rawAttributes[attrName].references) {
deps.push(dao.rawAttributes[attrName].references)
}
daos[dao.tableName] = dao
for (var attrName in dao.rawAttributes) {
if (dao.rawAttributes.hasOwnProperty(attrName)) {
(function(reference) {
if (!!reference) {
deps.push((reference instanceof DaoFactory) ? reference.tableName : reference)
}
})(dao.rawAttributes[attrName].references)
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!