zhike-chaos
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "zhike-chaos", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "chaos - boilerplate generator", | ||
@@ -5,0 +5,0 @@ "main": "bin/chaos", |
@@ -9,2 +9,3 @@ 'use strict'; | ||
const db = require('../src/common/db.js'); | ||
const log = require('rainbowlog'); | ||
@@ -15,3 +16,2 @@ // 加载models | ||
const dir = fs.readdirSync(cntPath).filter(exclude(['schemas', 'migrations', 'index.js'])); | ||
for (let i = 0; i < dir.length; i++) { | ||
@@ -29,8 +29,14 @@ if (fs.statSync(path.join(cntPath, dir[i])).isDirectory()) { | ||
const classMethods = require(path.join(cntPath, dir[i])); | ||
schemas[name].options.classMethods = classMethods; | ||
if (schemas[name] != null) { | ||
schemas[name].options.classMethods = classMethods; | ||
} else { | ||
log.warning(`Has no schema "${name}" but defined methods for it.`); | ||
} | ||
} | ||
const model = db.define(name, schemas[name].attributes, schemas[name].options); | ||
models[name] = model; | ||
} | ||
} | ||
for (const name of Object.keys(schemas)) { | ||
const model = db.define(name, schemas[name].attributes, schemas[name].options); | ||
models[name] = model; | ||
} | ||
}; | ||
@@ -37,0 +43,0 @@ |
41566
554