mirror of
https://github.com/thinkjs/thinkjs.git
synced 2026-01-25 14:42:47 +00:00
add dev doc
This commit is contained in:
parent
22da2b16f8
commit
080aec5a4b
26
doc/dev.md
Normal file
26
doc/dev.md
Normal 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/目录下,这样文件有修改后会自动编译。
|
||||
|
||||
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user