@asla/yoursql 0.7.0 → 0.7.1
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/dist/select/DbTable.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SqlSelectable } from "./selectable.ts";
|
|
2
|
-
import { ConditionParam, Constructable
|
|
2
|
+
import { ConditionParam, Constructable } from "../util.ts";
|
|
3
3
|
import type { TableType } from "./type.ts";
|
|
4
4
|
import { CurrentModifyWhere, CurrentOnConflict, CurrentWhere, Selection } from "./query_link.ts";
|
|
5
5
|
/**
|
|
@@ -13,10 +13,11 @@ export declare class DbTable<T extends TableType> extends SqlSelectable<T> {
|
|
|
13
13
|
/** 选择单表全部列 */
|
|
14
14
|
select(columns: "*", as?: string): CurrentWhere<T>;
|
|
15
15
|
/** 选择单表 */
|
|
16
|
+
select(columns: Constructable<Record<string, boolean | string> | string>, as?: string): CurrentWhere<Record<string, any>>;
|
|
17
|
+
/** 选择单表 */
|
|
16
18
|
select<R extends {}>(columns: Constructable<{
|
|
17
19
|
[key in keyof R]: boolean | string;
|
|
18
20
|
} | string>, as?: string): CurrentWhere<R>;
|
|
19
|
-
select<R extends {}>(columns: Constructable<SelectParam>): CurrentWhere<R>;
|
|
20
21
|
/**
|
|
21
22
|
* INSERT 语句,需要注意 SQL 注入
|
|
22
23
|
* @example
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SqlSelectable, SqlQueryStatement } from "./selectable.ts";
|
|
2
2
|
import { OrderByParam, ConditionParam, SelectParam, Constructable } from "../util.ts";
|
|
3
|
-
import type { ColumnsSelected,
|
|
3
|
+
import type { ColumnsSelected, TableType } from "./type.ts";
|
|
4
4
|
/** @public */
|
|
5
5
|
export interface CurrentLimit<T extends TableType> extends SqlQueryStatement<T> {
|
|
6
6
|
limit(limit?: number | bigint, offset?: number | bigint): SqlQueryStatement<T>;
|
|
@@ -35,7 +35,7 @@ export declare class Selection {
|
|
|
35
35
|
crossJoin(selectable: Constructable<SqlSelectable<any> | string>, as?: string | undefined): Selection;
|
|
36
36
|
from(selectable: Constructable<SqlSelectable<any> | string>, as?: string): Selection;
|
|
37
37
|
/** 选择全部列 */
|
|
38
|
-
select<T extends TableType =
|
|
38
|
+
select<T extends TableType = Record<string, any>>(columns: "*"): CurrentWhere<T>;
|
|
39
39
|
/**
|
|
40
40
|
* 自定义SQL选择语句
|
|
41
41
|
* @example
|
|
@@ -43,7 +43,7 @@ export declare class Selection {
|
|
|
43
43
|
* selection.select("t.age, count(*) AS c") // SELECT t.age,count(*) AS c FROM ...
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
select
|
|
46
|
+
select(columns: Constructable<SelectParam>): CurrentWhere<Record<string, any>>;
|
|
47
47
|
/**
|
|
48
48
|
* 通过 object 选择 列
|
|
49
49
|
* @example
|
|
@@ -53,14 +53,13 @@ export declare class Selection {
|
|
|
53
53
|
*/
|
|
54
54
|
select<T extends TableType>(columns: Constructable<{
|
|
55
55
|
[key in keyof T]: string | boolean;
|
|
56
|
-
}>): CurrentWhere<T>;
|
|
57
|
-
select<R extends {}>(columns: Constructable<SelectParam>): CurrentWhere<R>;
|
|
56
|
+
} | string>): CurrentWhere<T>;
|
|
58
57
|
}
|
|
59
58
|
/** @public */
|
|
60
59
|
export interface CurrentReturn<T extends TableType = {}> extends SqlQueryStatement<{}> {
|
|
61
60
|
returning(columns: "*"): SqlQueryStatement<T>;
|
|
62
|
-
returning
|
|
63
|
-
returning<R extends TableType>(columns: Constructable<R | string>): SqlQueryStatement<
|
|
61
|
+
returning(columns: Constructable<ColumnsSelected<T> | string>): SqlQueryStatement<Record<string, any>>;
|
|
62
|
+
returning<R extends TableType>(columns: Constructable<ColumnsSelected<R> | string>): SqlQueryStatement<R>;
|
|
64
63
|
}
|
|
65
64
|
/** @public */
|
|
66
65
|
export type CurrentModifyWhere<T extends TableType = {}> = CurrentReturn<T> & {
|
|
@@ -72,7 +71,7 @@ export type CurrentOnConflictDo<T extends TableType = {}> = {
|
|
|
72
71
|
/**
|
|
73
72
|
* 需要注意 SQL 注入
|
|
74
73
|
*/
|
|
75
|
-
doUpdate(set: Constructable<{
|
|
74
|
+
doUpdate(set: Constructable<string | {
|
|
76
75
|
[key in keyof T]?: string;
|
|
77
76
|
}>): CurrentModifyWhere<T>;
|
|
78
77
|
toString(): string;
|