Comparing version 1.2.1 to 1.2.2
@@ -795,5 +795,11 @@ 'use strict'; | ||
for (let k in orderby) { | ||
let v = table.model[k]; | ||
if (!v) | ||
continue; | ||
let ov; | ||
if (table.model) { | ||
let v = table.model[k]; | ||
if (!v) | ||
continue; | ||
ov = '`' + v.map + '`'; | ||
} else { | ||
ov = k; | ||
} | ||
@@ -805,3 +811,3 @@ if (first) | ||
sql2 += alip + '`' + v.map + '` '; | ||
sql2 += alip + ov + ' '; | ||
if (!orderby[k]) | ||
@@ -808,0 +814,0 @@ sql2 += 'DESC'; |
@@ -159,3 +159,3 @@ 'use strict'; | ||
var v = table._model[vv]; | ||
var v = table._model ? table._model[vv] : undefined; | ||
if (v != undefined) { | ||
@@ -162,0 +162,0 @@ sql1 += alias + '`' + vv + '`'; |
@@ -16,2 +16,8 @@ 'use strict'; | ||
const join_cross = require('./utils/join_cross'); | ||
const join_full_outer = require('./utils/join_full_outer'); | ||
const join_inner = require('./utils/join_inner'); | ||
const join_left_outer = require('./utils/join_left_outer'); | ||
const join_right_outer = require('./utils/join_right_outer'); | ||
module.exports = tablebase; | ||
@@ -187,2 +193,11 @@ | ||
/** | ||
* @desc: 返回join对象. | ||
*/ | ||
tablebase.prototype.join_inner = function(tableB) { return new join_inner(this.adapter, tableB); } | ||
tablebase.prototype.join_cross = function(tableB) { return new join_cross(this.adapter, tableB); } | ||
tablebase.prototype.join_left = function(tableB) { return new join_left_outer(this.adapter, tableB); } | ||
tablebase.prototype.join_right = function(tableB) { return new join_right_outer(this.adapter, tableB); } | ||
tablebase.prototype.join_full = function(tableB) { return new join_full_outer(this.adapter, tableB); } | ||
/** | ||
* @desc: 使用字段的映射名称获得字段的逻辑名称. | ||
@@ -189,0 +204,0 @@ * @return: string; 找不到返回undefined. |
@@ -54,3 +54,3 @@ { | ||
}, | ||
"version": "1.2.1" | ||
"version": "1.2.2" | ||
} |
127
README.md
@@ -33,2 +33,3 @@ febs db库用于连接数据库 | ||
- [Class dataType API](#class-datatype-api) | ||
- [Class join](#class-join) | ||
@@ -822,2 +823,7 @@ # Install | ||
- [db](#db) | ||
- [join_inner](#join_inner) | ||
- [join_cross](#join_cross) | ||
- [join_left](#join_left) | ||
- [join_right](#join_right) | ||
- [join_full](#join_full) | ||
@@ -1058,2 +1064,48 @@ ### constructor | ||
### join_inner | ||
```js | ||
/** | ||
* @desc: join tableB后, 返回join对象. | ||
*/ | ||
join_inner(tableB) | ||
``` | ||
### join_cross | ||
```js | ||
/** | ||
* @desc: join tableB后, 返回join对象. | ||
*/ | ||
join_cross(tableB) | ||
``` | ||
### join_left | ||
```js | ||
/** | ||
* @desc: join tableB后, 返回join对象. | ||
*/ | ||
join_left(tableB) | ||
``` | ||
### join_right | ||
```js | ||
/** | ||
* @desc: join tableB后, 返回join对象. | ||
*/ | ||
join_right(tableB) | ||
``` | ||
### join_full | ||
```js | ||
/** | ||
* @desc: join tableB后, 返回join对象. | ||
*/ | ||
join_full(tableB) | ||
``` | ||
# Class condition API | ||
@@ -1248,2 +1300,75 @@ | ||
getValueBit(sqlValue) | ||
``` | ||
``` | ||
# Class join | ||
- [sql_select](#sql_select-1) | ||
- [set_alias1](#set_alias1) | ||
- [set_alias2](#set_alias2) | ||
- [set_on](#set_on) | ||
- [table1](#table1) | ||
- [table2](#table1) | ||
- [alias1](#alias1) | ||
- [alias2](#alias1) | ||
### sql_select | ||
```js | ||
/** | ||
* @desc: 返回sql select. | ||
* 查询的字段必须明确指明. | ||
* @return: string | ||
*/ | ||
sql_select(where, opt = null) | ||
``` | ||
### set_alias1 | ||
```js | ||
/** | ||
* @desc: 设置别名1. | ||
* @return: 支持语法糖 | ||
*/ | ||
set_alias1(aliasName) | ||
``` | ||
### set_alias2 | ||
```js | ||
/** | ||
* @desc: 设置别名2. | ||
* @return: 支持语法糖 | ||
*/ | ||
set_alias2(aliasName) | ||
``` | ||
### set_on | ||
```js | ||
/** | ||
* @desc: 设置join条件. | ||
* @return: 支持语法糖 | ||
*/ | ||
set_on(onSql) | ||
``` | ||
### table1 | ||
```js | ||
/** | ||
* @desc: table1对象. table2对象. | ||
*/ | ||
get table1; | ||
get table2; | ||
``` | ||
### alias1 | ||
```js | ||
/** | ||
* @desc: table1对象别名. table2对象别名. | ||
*/ | ||
get alias1; | ||
get alias2; | ||
``` |
@@ -253,2 +253,44 @@ // Type definitions for febs | ||
export class join { | ||
/** | ||
* @desc: 返回sql select. | ||
* @return: string | ||
*/ | ||
sql_select(where:string, opt?:select_opt):string; | ||
/** | ||
* @desc: 设置别名1. | ||
* @return: 支持语法糖 | ||
*/ | ||
set_alias1(aliasName:string):join; | ||
/** | ||
* @desc: 设置别名2. | ||
* @return: 支持语法糖 | ||
*/ | ||
set_alias2(aliasName:string):join; | ||
/** | ||
* @desc: 设置join条件. | ||
* @return: 支持语法糖 | ||
*/ | ||
set_on(onSql:string):join; | ||
/** | ||
* @desc: table1. | ||
*/ | ||
table1: string; | ||
/** | ||
* @desc: table2. | ||
*/ | ||
table2: string; | ||
/** | ||
* @desc: alias1. | ||
*/ | ||
alias1: string; | ||
/** | ||
* @desc: alias2. | ||
*/ | ||
alias2: string; | ||
} | ||
export class tablebase { | ||
@@ -377,3 +419,13 @@ /** | ||
/** | ||
* @desc: 返回join对象. | ||
*/ | ||
join_inner(tableB:tablebase):join; | ||
join_cross(tableB:tablebase):join; | ||
join_left(tableB:tablebase):join; | ||
join_right(tableB:tablebase):join; | ||
join_full(tableB:tablebase):join; | ||
/** | ||
* @desc: 真实表名称. | ||
@@ -380,0 +432,0 @@ */ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
263510
46
4782
1371