@axiosleo/orm-mysql 0.12.0 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/orm-mysql.js +1 -1
- package/index.d.ts +4 -3
- package/package.json +1 -1
- package/src/builder.js +3 -3
package/bin/orm-mysql.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export type OptType = '=' | '!=' | '>' | '<' | '>=' | '<=' |
|
|
|
25
25
|
'LIKE' | 'NOT LIKE' | 'IN' | 'NOT IN' | 'BETWEEN' | 'NOT BETWEEN' | 'IS' | 'IS NOT' | 'REGEXP' | 'NOT REGEXP' | 'AND' | 'OR' | 'GROUP' | 'CONTAIN' | 'NOT CONTAIN' | 'OVERLAPS' | 'NOT OVERLAPS' |
|
|
26
26
|
'like' | 'not like' | 'in' | 'not in' | 'between' | 'not between' | 'is' | 'is not' | 'regexp' | 'not regexp' | 'and' | 'or' | 'group' | 'contain' | 'not contain' | 'overlaps' | 'not overlaps';
|
|
27
27
|
|
|
28
|
+
export type SortOrderType = 'asc' | 'desc' | 'ASC' | 'DESC';
|
|
28
29
|
export interface WhereOptions {
|
|
29
30
|
key: string | null;
|
|
30
31
|
opt: OptType;
|
|
@@ -38,7 +39,7 @@ export type WhereItem = WhereOptions | OptType | WhereArrayOptions;
|
|
|
38
39
|
|
|
39
40
|
export interface OrderByOptions {
|
|
40
41
|
sortField: string,
|
|
41
|
-
sortOrder:
|
|
42
|
+
sortOrder: SortOrderType
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
export type OperatorType = 'select' | 'find' | 'insert' | 'update' | 'delete' | 'count';
|
|
@@ -192,9 +193,9 @@ export declare class Query extends QueryCondition {
|
|
|
192
193
|
/**
|
|
193
194
|
* Add an ORDER BY clause to the query
|
|
194
195
|
* @param sortField Field name to sort by
|
|
195
|
-
* @param sortOrder Sort order ('asc' or 'desc')
|
|
196
|
+
* @param sortOrder Sort order ('asc' or 'desc' or 'ASC' or 'DESC')
|
|
196
197
|
*/
|
|
197
|
-
orderBy(sortField: string, sortOrder:
|
|
198
|
+
orderBy(sortField: string, sortOrder: SortOrderType): this;
|
|
198
199
|
|
|
199
200
|
/**
|
|
200
201
|
* Add a GROUP BY clause to the query
|
package/package.json
CHANGED
package/src/builder.js
CHANGED
|
@@ -231,7 +231,7 @@ class Builder {
|
|
|
231
231
|
return '';
|
|
232
232
|
}
|
|
233
233
|
const sql = 'ORDER BY ' + orders.map((o) => {
|
|
234
|
-
return `${this._buildFieldKey(o.sortField)} ${o.sortOrder}`;
|
|
234
|
+
return `${this._buildFieldKey(o.sortField)} ${o.sortOrder.toUpperCase()}`;
|
|
235
235
|
}).join(',');
|
|
236
236
|
return sql;
|
|
237
237
|
}
|
|
@@ -710,7 +710,7 @@ class ManageSQLBuilder extends Builder {
|
|
|
710
710
|
let str = `\`${options.name}\` ${type}`;
|
|
711
711
|
if (typeof options.length !== 'undefined') {
|
|
712
712
|
if (type === 'DECIMAL') {
|
|
713
|
-
str += `(${options.
|
|
713
|
+
str += `(${options.precision || 10}, ${options.length || 6})`;
|
|
714
714
|
} else {
|
|
715
715
|
str += `(${options.length})`;
|
|
716
716
|
}
|
|
@@ -721,7 +721,7 @@ class ManageSQLBuilder extends Builder {
|
|
|
721
721
|
} else if (type === 'TINYINT') {
|
|
722
722
|
str += '(4)';
|
|
723
723
|
} else if (type === 'DECIMAL') {
|
|
724
|
-
str +=
|
|
724
|
+
str += `(${options.precision || 10}, ${options.length || 6})`;
|
|
725
725
|
}
|
|
726
726
|
if (options.allowNull === false || options.primaryKey === true) {
|
|
727
727
|
str += ' NOT NULL';
|