add dev doc

This commit is contained in:
welefen 2015-05-22 13:09:05 +08:00
parent 22da2b16f8
commit 080aec5a4b
3 changed files with 29 additions and 7 deletions

26
doc/dev.md Normal file
View File

@ -0,0 +1,26 @@
## 2.0开发文档
### 介绍
`https://github.com/75team/thinkjs`上拉取代码后,选择`es6`的分支。
2.0基于ES6特性进行开发如果对ES6不够了解请先熟练了解ES6的特性 http://es6.ruanyifeng.com/#README
由于有些特性目前Node还不支持所以需要使用`Babel`来编译成Es5的代码运行。http://babeljs.io/
安装Babel
```
npm install -g babel
```
然后对src目录进行编译
```
babel --loose all --optional runtime --stage 0 src/ --out-dir lib/ --watch
```
上面代码表示用监听的方式将src/目录编译到lib/目录下,这样文件有修改后会自动编译。

View File

@ -18,7 +18,6 @@
"dependencies": {
"swig": "1.4.2",
"multiparty": "4.0.0",
"es6-promise": "2.0.0",
"mime": "1.2.11",
"mysql": "2.5.3",
"websocket-driver": "0.4.0",

View File

@ -25,6 +25,7 @@ module.exports = class extends think.base {
trueTableName: '',
fields: {}
}
//if user model is set, can't be override
for(let key in options){
if(this[key] === undefined){
this[key] = options[key];
@ -126,12 +127,8 @@ module.exports = class extends think.base {
let fields = await this.getTableFields();
let result = [];
for(let name in fields){
if(fields[name].unique){
if(!data){
return name;
}else if(data[name]){
return name;
}
if(fields[name].unique && (!data || data[name])){
return name;
}
}
}