This commit is contained in:
welefen 2014-01-07 17:40:10 +08:00
parent 51f3ecf286
commit 4fa38f684f
3 changed files with 10 additions and 9 deletions

View File

@ -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: "",// 数据库名

View File

@ -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);

View File

@ -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);
};