diff --git a/lib/Conf/config.js b/lib/Conf/config.js index db4fc327..196dc508 100644 --- a/lib/Conf/config.js +++ b/lib/Conf/config.js @@ -45,6 +45,9 @@ module.exports = { session_options: {}, //session的一些选项 session_cookie_sign: "", //session对应的cookie使用签名,如果使用这里填密钥 + load_ext_config: [], //加载额外的配置文件 CONF_PATH + load_ext_file: [], //加载额外的文件 COMMON_PATH + db_type: "mysql", // 数据库类型 db_host: "localhost",// 服务器地址 db_name: "",// 数据库名 diff --git a/lib/Lib/Core/Model.class.js b/lib/Lib/Core/Model.class.js index 46c5c8f1..91c4f93e 100644 --- a/lib/Lib/Core/Model.class.js +++ b/lib/Lib/Core/Model.class.js @@ -188,9 +188,6 @@ var Model = module.exports = Class(function(){ }; if (table) { return this.db.getFields(table).then(function(data){ - if (data === false) { - return []; - }; var fields = { "_field": Object.keys(data || {}), "_autoinc": false @@ -493,8 +490,8 @@ var Model = module.exports = Class(function(){ if (id) { data[self.getPk()] = id; }; - self._afterInsert(data, options); - return id; + data = self._afterInsert(data, options); + return data[self.getPk()]; }); }); }, @@ -548,7 +545,8 @@ var Model = module.exports = Class(function(){ var self = this; return this.parseOptions(options).then(function(options){ data = self.parseData(data); - if (self._beforeUpdate(data, options) === false) { + data = self._beforeUpdate(data, options); + if ( data === false) { return getPromise("_beforeUpdate return false", true); }; var pkValue = ""; @@ -570,7 +568,7 @@ var Model = module.exports = Class(function(){ if (pkValue) { data[pk] = pkValue; }; - self._afterUpdate(data, options); + data = self._afterUpdate(data, options); return data.affectedRows; }; return false; @@ -753,7 +751,7 @@ var Model = module.exports = Class(function(){ "__TABLE__": this.getTableName(), "__PREFIX__": C('db_prefix') }; - sql = sql.replace(/__[A-Z]__/g, function(a){ + sql = sql.replace(/__[A-Z]+__/g, function(a){ return map[a] || a; }) promise = getPromise(sql); diff --git a/lib/Lib/Core/Think.class.js b/lib/Lib/Core/Think.class.js index 35a5986d..95ab859c 100644 --- a/lib/Lib/Core/Think.class.js +++ b/lib/Lib/Core/Think.class.js @@ -79,7 +79,7 @@ module.exports = { files = files.split(','); }; files.forEach(function(file){ - file = COMMONT_PATH + "/" + file + ".js"; + file = COMMON_PATH + "/" + file + ".js"; if (isFile(file)) { require(file); };