wok-server 0.7.2 → 0.8.0

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.
Files changed (41) hide show
  1. package/README.md +101 -14
  2. package/dist/http-client/index.js +1 -2
  3. package/dist/lock/index.js +5 -2
  4. package/dist/mvc/config.js +4 -2
  5. package/dist/mvc/exchange.js +32 -7
  6. package/dist/mvc/index.js +1 -1
  7. package/dist/mvc/server.js +12 -4
  8. package/dist/mysql/manager/base.js +5 -8
  9. package/dist/mysql/manager/ops/delete.js +2 -1
  10. package/dist/mysql/manager/ops/find.js +8 -4
  11. package/dist/mysql/manager/ops/insert.js +15 -40
  12. package/dist/mysql/manager/ops/update.js +2 -1
  13. package/dist/mysql/manager/ops/upsert.js +11 -31
  14. package/dist/mysql/migration.js +10 -3
  15. package/documentation/en/mysql.md +26 -33
  16. package/documentation/zh-cn/mysql.md +27 -34
  17. package/documentation/zh-cn/philosophy.md +433 -0
  18. package/package.json +1 -1
  19. package/skills/wok-server-api-rules/SKILL.md +113 -0
  20. package/skills/wok-server-code-navigation/SKILL.md +169 -95
  21. package/skills/wok-server-mysql/SKILL.md +16 -10
  22. package/skills/wok-server-mysql/references/version-control.md +7 -5
  23. package/src/http-client/index.ts +0 -1
  24. package/src/lock/index.ts +5 -2
  25. package/src/mvc/config.ts +9 -2
  26. package/src/mvc/exchange.ts +31 -6
  27. package/src/mvc/index.ts +1 -1
  28. package/src/mvc/server.ts +11 -5
  29. package/src/mysql/manager/base.ts +17 -17
  30. package/src/mysql/manager/ops/delete.ts +2 -1
  31. package/src/mysql/manager/ops/find.ts +8 -4
  32. package/src/mysql/manager/ops/insert.ts +23 -61
  33. package/src/mysql/manager/ops/update.ts +2 -1
  34. package/src/mysql/manager/ops/upsert.ts +31 -51
  35. package/src/mysql/migration.ts +14 -3
  36. package/types/lock/index.d.ts +3 -0
  37. package/types/mvc/config.d.ts +5 -0
  38. package/types/mvc/exchange.d.ts +13 -3
  39. package/types/mysql/manager/base.d.ts +12 -12
  40. package/types/mysql/manager/ops/insert.d.ts +2 -16
  41. package/types/mysql/manager/ops/upsert.d.ts +3 -4
@@ -1,20 +1,6 @@
1
1
  import { PoolConnection } from 'mysql2';
2
2
  import { Table } from '../../table-info';
3
3
  import { MysqlConfig } from '../../config';
4
- /**
5
- * 插入值类型,支持在 INSERT VALUES 中使用表达式
6
- */
7
- export type InsertValue<T> = {
8
- [K in keyof T]?: T[K] | ['now'] | ['set', T[K]] | ['expr', string] | ['expr', string, any[]];
9
- };
10
- /**
11
- * 处理 insert value,支持表达式
12
- * @returns { frag: SQL 片段, values: 参数值数组 }
13
- */
14
- export declare function processInsertValue(value: any): {
15
- frag: string;
16
- values: any[];
17
- };
18
4
  /**
19
5
  * 为表插入数据
20
6
  * @param connection
@@ -22,11 +8,11 @@ export declare function processInsertValue(value: any): {
22
8
  * @param data
23
9
  * @returns
24
10
  */
25
- export declare function insert<T>(config: MysqlConfig, connection: PoolConnection, table: Table<T>, data: InsertValue<T>): Promise<T>;
11
+ export declare function insert<T>(config: MysqlConfig, connection: PoolConnection, table: Table<T>, data: T): Promise<T>;
26
12
  /**
27
13
  * 一次插入多条记录
28
14
  * @param connection 连接
29
15
  * @param table 表
30
16
  * @param list 要插入的记录列表
31
17
  */
32
- export declare function insertMany<T>(config: MysqlConfig, connection: PoolConnection, table: Table<T>, list: InsertValue<T>[]): Promise<void>;
18
+ export declare function insertMany<T>(config: MysqlConfig, connection: PoolConnection, table: Table<T>, list: T[]): Promise<void>;
@@ -1,7 +1,6 @@
1
1
  import { PoolConnection } from 'mysql2';
2
2
  import { MysqlConfig } from '../../config';
3
3
  import { Table } from '../../table-info';
4
- import { InsertValue } from './insert';
5
4
  import { Updater } from './update';
6
5
  /**
7
6
  * Upsert 单条数据
@@ -12,7 +11,7 @@ import { Updater } from './update';
12
11
  * @param data
13
12
  * @returns
14
13
  */
15
- export declare function upsert<T>(config: MysqlConfig, connection: PoolConnection, table: Table<T>, data: InsertValue<T>): Promise<T>;
14
+ export declare function upsert<T>(config: MysqlConfig, connection: PoolConnection, table: Table<T>, data: T): Promise<T>;
16
15
  /**
17
16
  * Upsert 多条数据
18
17
  * 如果主键冲突则更新,否则插入
@@ -22,7 +21,7 @@ export declare function upsert<T>(config: MysqlConfig, connection: PoolConnectio
22
21
  * @param list
23
22
  * @returns 影响的行数
24
23
  */
25
- export declare function upsertMany<T>(config: MysqlConfig, connection: PoolConnection, table: Table<T>, list: InsertValue<T>[]): Promise<number>;
24
+ export declare function upsertMany<T>(config: MysqlConfig, connection: PoolConnection, table: Table<T>, list: T[]): Promise<number>;
26
25
  /**
27
26
  * Upsert 单条数据(支持自定义更新器)
28
27
  * 如果主键冲突则按自定义逻辑更新,否则插入
@@ -33,4 +32,4 @@ export declare function upsertMany<T>(config: MysqlConfig, connection: PoolConne
33
32
  * @param updater 冲突时的更新器
34
33
  * @returns
35
34
  */
36
- export declare function upsertWithUpdater<T>(config: MysqlConfig, connection: PoolConnection, table: Table<T>, data: InsertValue<T>, updater: Updater<T>): Promise<T>;
35
+ export declare function upsertWithUpdater<T>(config: MysqlConfig, connection: PoolConnection, table: Table<T>, data: T, updater: Updater<T>): Promise<T>;