@maiyunnet/kebab 9.4.0 → 9.5.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.
- package/doc/kebab-rag.md +136 -94
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/core.d.ts +1 -1
- package/lib/sql.d.ts +15 -0
- package/lib/sql.js +95 -0
- package/lib/undici/response.d.ts +1 -1
- package/package.json +1 -1
- package/sys/master.js +38 -22
- package/sys/mod.js +30 -53
- package/www/example/ctr/test.js +13 -3
package/doc/kebab-rag.md
CHANGED
|
@@ -1360,7 +1360,7 @@ index/variables/VER.md
|
|
|
1360
1360
|
|
|
1361
1361
|
# Variable: VER
|
|
1362
1362
|
|
|
1363
|
-
> `const` **VER**: `"9.
|
|
1363
|
+
> `const` **VER**: `"9.5.0"` = `'9.5.0'`
|
|
1364
1364
|
|
|
1365
1365
|
Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
|
|
1366
1366
|
|
|
@@ -3460,7 +3460,7 @@ lib/core/functions/getLog.md
|
|
|
3460
3460
|
|
|
3461
3461
|
# Function: getLog()
|
|
3462
3462
|
|
|
3463
|
-
> **getLog**(`opt`): `Promise`\<`false` \| `string`[][] \| `null`\>
|
|
3463
|
+
> **getLog**(`opt`): `Promise`\<`false` \| `any`[] \| `string`[][] \| `null`\>
|
|
3464
3464
|
|
|
3465
3465
|
Defined in: [lib/core.ts:1031](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1031)
|
|
3466
3466
|
|
|
@@ -3522,7 +3522,7 @@ Defined in: [lib/core.ts:1031](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
3522
3522
|
|
|
3523
3523
|
## Returns
|
|
3524
3524
|
|
|
3525
|
-
`Promise`\<`false` \| `string`[][] \| `null`\>
|
|
3525
|
+
`Promise`\<`false` \| `any`[] \| `string`[][] \| `null`\>
|
|
3526
3526
|
|
|
3527
3527
|
lib/core/functions/ip.md
|
|
3528
3528
|
---
|
|
@@ -13675,7 +13675,7 @@ Defined in: [lib/sql.ts:69](https://github.com/maiyunnet/kebab/blob/master/lib/s
|
|
|
13675
13675
|
|
|
13676
13676
|
> **append**(`sql`): `this`
|
|
13677
13677
|
|
|
13678
|
-
Defined in: [lib/sql.ts:
|
|
13678
|
+
Defined in: [lib/sql.ts:980](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L980)
|
|
13679
13679
|
|
|
13680
13680
|
在 sql 最后追加字符串
|
|
13681
13681
|
|
|
@@ -13695,7 +13695,7 @@ Defined in: [lib/sql.ts:926](https://github.com/maiyunnet/kebab/blob/master/lib/
|
|
|
13695
13695
|
|
|
13696
13696
|
> **by**(`c`, `d?`): `this`
|
|
13697
13697
|
|
|
13698
|
-
Defined in: [lib/sql.ts:
|
|
13698
|
+
Defined in: [lib/sql.ts:736](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L736)
|
|
13699
13699
|
|
|
13700
13700
|
ORDER BY
|
|
13701
13701
|
|
|
@@ -13723,7 +13723,7 @@ ORDER BY
|
|
|
13723
13723
|
|
|
13724
13724
|
> **copy**(`f?`, `opt?`): `Sql`
|
|
13725
13725
|
|
|
13726
|
-
Defined in: [lib/sql.ts:
|
|
13726
|
+
Defined in: [lib/sql.ts:804](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L804)
|
|
13727
13727
|
|
|
13728
13728
|
创建一个本对象的一个新的 sql 对象拷贝
|
|
13729
13729
|
|
|
@@ -13751,7 +13751,7 @@ Defined in: [lib/sql.ts:750](https://github.com/maiyunnet/kebab/blob/master/lib/
|
|
|
13751
13751
|
|
|
13752
13752
|
> **crossJoin**(`f`, `s?`, `suf?`, `pre?`): `this`
|
|
13753
13753
|
|
|
13754
|
-
Defined in: [lib/sql.ts:
|
|
13754
|
+
Defined in: [lib/sql.ts:485](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L485)
|
|
13755
13755
|
|
|
13756
13756
|
cross join 方法
|
|
13757
13757
|
|
|
@@ -13791,7 +13791,7 @@ MySQL 时为表前缀,PostgreSQL 时为 Schema 名,仅在 join 非默认前
|
|
|
13791
13791
|
|
|
13792
13792
|
> **delete**(`f`): `this`
|
|
13793
13793
|
|
|
13794
|
-
Defined in: [lib/sql.ts:
|
|
13794
|
+
Defined in: [lib/sql.ts:373](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L373)
|
|
13795
13795
|
|
|
13796
13796
|
'xx'
|
|
13797
13797
|
|
|
@@ -13813,7 +13813,7 @@ Defined in: [lib/sql.ts:319](https://github.com/maiyunnet/kebab/blob/master/lib/
|
|
|
13813
13813
|
|
|
13814
13814
|
> **field**(`str`, `pre?`, `suf?`): `string`
|
|
13815
13815
|
|
|
13816
|
-
Defined in: [lib/sql.ts:
|
|
13816
|
+
Defined in: [lib/sql.ts:991](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L991)
|
|
13817
13817
|
|
|
13818
13818
|
对字段进行包裹
|
|
13819
13819
|
|
|
@@ -13845,7 +13845,7 @@ MySQL 时为表前缀,PostgreSQL 时为 Schema 名,仅请在 field 表名时
|
|
|
13845
13845
|
|
|
13846
13846
|
> **format**(`sql?`, `data?`): `string`
|
|
13847
13847
|
|
|
13848
|
-
Defined in: [lib/sql.ts:
|
|
13848
|
+
Defined in: [lib/sql.ts:970](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L970)
|
|
13849
13849
|
|
|
13850
13850
|
获取带 data 的 sql 语句
|
|
13851
13851
|
|
|
@@ -13869,7 +13869,7 @@ Defined in: [lib/sql.ts:916](https://github.com/maiyunnet/kebab/blob/master/lib/
|
|
|
13869
13869
|
|
|
13870
13870
|
> **fullJoin**(`f`, `s?`, `suf?`, `pre?`): `this`
|
|
13871
13871
|
|
|
13872
|
-
Defined in: [lib/sql.ts:
|
|
13872
|
+
Defined in: [lib/sql.ts:474](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L474)
|
|
13873
13873
|
|
|
13874
13874
|
full join 方法
|
|
13875
13875
|
|
|
@@ -13909,7 +13909,7 @@ MySQL 时为表前缀,PostgreSQL 时为 Schema 名,仅在 join 非默认前
|
|
|
13909
13909
|
|
|
13910
13910
|
> **getData**(): [`DbValue`](../../../index/type-aliases/DbValue.md)[]
|
|
13911
13911
|
|
|
13912
|
-
Defined in: [lib/sql.ts:
|
|
13912
|
+
Defined in: [lib/sql.ts:954](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L954)
|
|
13913
13913
|
|
|
13914
13914
|
获取全部 data
|
|
13915
13915
|
|
|
@@ -13923,7 +13923,7 @@ Defined in: [lib/sql.ts:900](https://github.com/maiyunnet/kebab/blob/master/lib/
|
|
|
13923
13923
|
|
|
13924
13924
|
> **getPre**(): `string`
|
|
13925
13925
|
|
|
13926
|
-
Defined in: [lib/sql.ts:
|
|
13926
|
+
Defined in: [lib/sql.ts:961](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L961)
|
|
13927
13927
|
|
|
13928
13928
|
获取定义的 pre
|
|
13929
13929
|
|
|
@@ -13937,7 +13937,7 @@ Defined in: [lib/sql.ts:907](https://github.com/maiyunnet/kebab/blob/master/lib/
|
|
|
13937
13937
|
|
|
13938
13938
|
> **getSql**(): `string`
|
|
13939
13939
|
|
|
13940
|
-
Defined in: [lib/sql.ts:
|
|
13940
|
+
Defined in: [lib/sql.ts:938](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L938)
|
|
13941
13941
|
|
|
13942
13942
|
获取 sql 语句
|
|
13943
13943
|
|
|
@@ -13951,7 +13951,7 @@ Defined in: [lib/sql.ts:884](https://github.com/maiyunnet/kebab/blob/master/lib/
|
|
|
13951
13951
|
|
|
13952
13952
|
> **group**(`c`): `this`
|
|
13953
13953
|
|
|
13954
|
-
Defined in: [lib/sql.ts:
|
|
13954
|
+
Defined in: [lib/sql.ts:760](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L760)
|
|
13955
13955
|
|
|
13956
13956
|
GROUP BY
|
|
13957
13957
|
|
|
@@ -13973,7 +13973,7 @@ GROUP BY
|
|
|
13973
13973
|
|
|
13974
13974
|
> **having**(`s?`): `this`
|
|
13975
13975
|
|
|
13976
|
-
Defined in: [lib/sql.ts:
|
|
13976
|
+
Defined in: [lib/sql.ts:492](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L492)
|
|
13977
13977
|
|
|
13978
13978
|
having 后置筛选器,用法类似 where
|
|
13979
13979
|
|
|
@@ -13993,7 +13993,7 @@ having 后置筛选器,用法类似 where
|
|
|
13993
13993
|
|
|
13994
13994
|
> **innerJoin**(`f`, `s?`, `suf?`, `pre?`): `this`
|
|
13995
13995
|
|
|
13996
|
-
Defined in: [lib/sql.ts:
|
|
13996
|
+
Defined in: [lib/sql.ts:463](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L463)
|
|
13997
13997
|
|
|
13998
13998
|
inner join 方法
|
|
13999
13999
|
|
|
@@ -14061,7 +14061,7 @@ Defined in: [lib/sql.ts:99](https://github.com/maiyunnet/kebab/blob/master/lib/s
|
|
|
14061
14061
|
|
|
14062
14062
|
> **join**(`f`, `s?`, `type?`, `suf?`, `pre?`): `this`
|
|
14063
14063
|
|
|
14064
|
-
Defined in: [lib/sql.ts:
|
|
14064
|
+
Defined in: [lib/sql.ts:415](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L415)
|
|
14065
14065
|
|
|
14066
14066
|
join 方法
|
|
14067
14067
|
|
|
@@ -14107,7 +14107,7 @@ MySQL 时为表前缀,PostgreSQL 时为 Schema 名,仅在 join 非默认前
|
|
|
14107
14107
|
|
|
14108
14108
|
> **leftJoin**(`f`, `s?`, `suf?`, `pre?`): `this`
|
|
14109
14109
|
|
|
14110
|
-
Defined in: [lib/sql.ts:
|
|
14110
|
+
Defined in: [lib/sql.ts:441](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L441)
|
|
14111
14111
|
|
|
14112
14112
|
left join 方法
|
|
14113
14113
|
|
|
@@ -14147,7 +14147,7 @@ MySQL 时为表前缀,PostgreSQL 时为 Schema 名,仅在 join 非默认前
|
|
|
14147
14147
|
|
|
14148
14148
|
> **limit**(`a`, `b?`): `this`
|
|
14149
14149
|
|
|
14150
|
-
Defined in: [lib/sql.ts:
|
|
14150
|
+
Defined in: [lib/sql.ts:780](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L780)
|
|
14151
14151
|
|
|
14152
14152
|
LIMIT(limit、offset, limit)
|
|
14153
14153
|
|
|
@@ -14175,7 +14175,7 @@ LIMIT(limit、offset, limit)
|
|
|
14175
14175
|
|
|
14176
14176
|
> **lock**(): `this`
|
|
14177
14177
|
|
|
14178
|
-
Defined in: [lib/sql.ts:
|
|
14178
|
+
Defined in: [lib/sql.ts:795](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L795)
|
|
14179
14179
|
|
|
14180
14180
|
追加消极锁,通常不建议使用
|
|
14181
14181
|
|
|
@@ -14189,7 +14189,7 @@ Defined in: [lib/sql.ts:741](https://github.com/maiyunnet/kebab/blob/master/lib/
|
|
|
14189
14189
|
|
|
14190
14190
|
> **rightJoin**(`f`, `s?`, `suf?`, `pre?`): `this`
|
|
14191
14191
|
|
|
14192
|
-
Defined in: [lib/sql.ts:
|
|
14192
|
+
Defined in: [lib/sql.ts:452](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L452)
|
|
14193
14193
|
|
|
14194
14194
|
right join 方法
|
|
14195
14195
|
|
|
@@ -14229,7 +14229,7 @@ MySQL 时为表前缀,PostgreSQL 时为 Schema 名,仅在 join 非默认前
|
|
|
14229
14229
|
|
|
14230
14230
|
> **select**(`c`, `f`): `this`
|
|
14231
14231
|
|
|
14232
|
-
Defined in: [lib/sql.ts:
|
|
14232
|
+
Defined in: [lib/sql.ts:264](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L264)
|
|
14233
14233
|
|
|
14234
14234
|
'*', 'xx'
|
|
14235
14235
|
|
|
@@ -14257,7 +14257,7 @@ Defined in: [lib/sql.ts:210](https://github.com/maiyunnet/kebab/blob/master/lib/
|
|
|
14257
14257
|
|
|
14258
14258
|
> **union**(`lsql`, `type?`): `this`
|
|
14259
14259
|
|
|
14260
|
-
Defined in: [lib/sql.ts:
|
|
14260
|
+
Defined in: [lib/sql.ts:385](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L385)
|
|
14261
14261
|
|
|
14262
14262
|
联查另一个 sql 对象
|
|
14263
14263
|
|
|
@@ -14285,7 +14285,7 @@ sql 对象
|
|
|
14285
14285
|
|
|
14286
14286
|
> **unionAll**(`lsql`): `this`
|
|
14287
14287
|
|
|
14288
|
-
Defined in: [lib/sql.ts:
|
|
14288
|
+
Defined in: [lib/sql.ts:403](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L403)
|
|
14289
14289
|
|
|
14290
14290
|
所有联查另一个 sql 对象
|
|
14291
14291
|
|
|
@@ -14307,7 +14307,7 @@ sql 对象
|
|
|
14307
14307
|
|
|
14308
14308
|
> **update**(`f`, `s`): `this`
|
|
14309
14309
|
|
|
14310
|
-
Defined in: [lib/sql.ts:
|
|
14310
|
+
Defined in: [lib/sql.ts:305](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L305)
|
|
14311
14311
|
|
|
14312
14312
|
UPDATE SQL 方法
|
|
14313
14313
|
|
|
@@ -14331,6 +14331,48 @@ UPDATE SQL 方法
|
|
|
14331
14331
|
|
|
14332
14332
|
***
|
|
14333
14333
|
|
|
14334
|
+
### updateByValues()
|
|
14335
|
+
|
|
14336
|
+
> **updateByValues**(`table`, `key`, `cols`, `rows`): `this`
|
|
14337
|
+
|
|
14338
|
+
Defined in: [lib/sql.ts:214](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L214)
|
|
14339
|
+
|
|
14340
|
+
批量 UPDATE,以子查询作为数据源,纯更新语义(不会插入新行)
|
|
14341
|
+
MySQL: UPDATE t INNER JOIN (SELECT col AS alias ... UNION ALL SELECT ...) AS tmp ON t.key=tmp.key SET t.c=tmp.c
|
|
14342
|
+
PostgreSQL: UPDATE t SET c=tmp.c FROM (VALUES ($1,...)) AS tmp(cols) WHERE t.key=tmp.key
|
|
14343
|
+
|
|
14344
|
+
#### Parameters
|
|
14345
|
+
|
|
14346
|
+
##### table
|
|
14347
|
+
|
|
14348
|
+
`string`
|
|
14349
|
+
|
|
14350
|
+
表名
|
|
14351
|
+
|
|
14352
|
+
##### key
|
|
14353
|
+
|
|
14354
|
+
`string`
|
|
14355
|
+
|
|
14356
|
+
用于定位的主键/唯一键字段名
|
|
14357
|
+
|
|
14358
|
+
##### cols
|
|
14359
|
+
|
|
14360
|
+
`string`[]
|
|
14361
|
+
|
|
14362
|
+
要更新的列名数组(不含 key)
|
|
14363
|
+
|
|
14364
|
+
##### rows
|
|
14365
|
+
|
|
14366
|
+
`any`[][]
|
|
14367
|
+
|
|
14368
|
+
数据行数组,每行顺序为 [keyVal, col1Val, col2Val, ...](与 [key, ...cols] 对应)
|
|
14369
|
+
|
|
14370
|
+
#### Returns
|
|
14371
|
+
|
|
14372
|
+
`this`
|
|
14373
|
+
|
|
14374
|
+
***
|
|
14375
|
+
|
|
14334
14376
|
### upsert()
|
|
14335
14377
|
|
|
14336
14378
|
> **upsert**(`data`, `conflict?`): `this`
|
|
@@ -14391,7 +14433,7 @@ Defined in: [lib/sql.ts:118](https://github.com/maiyunnet/kebab/blob/master/lib/
|
|
|
14391
14433
|
|
|
14392
14434
|
> **where**(`s`): `this`
|
|
14393
14435
|
|
|
14394
|
-
Defined in: [lib/sql.ts:
|
|
14436
|
+
Defined in: [lib/sql.ts:526](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L526)
|
|
14395
14437
|
|
|
14396
14438
|
筛选器
|
|
14397
14439
|
1. 'city': 'bj', 'type': '2'
|
|
@@ -14534,7 +14576,7 @@ lib/sql/functions/aoMix.md
|
|
|
14534
14576
|
|
|
14535
14577
|
> **aoMix**(`arr`): `Record`\<`string`, `string` \| `number` \| [`Json`](../../../index/type-aliases/Json.md)\>
|
|
14536
14578
|
|
|
14537
|
-
Defined in: [lib/sql.ts:
|
|
14579
|
+
Defined in: [lib/sql.ts:1376](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1376)
|
|
14538
14580
|
|
|
14539
14581
|
将数组兑换为组合的对象(Array/Object mix)
|
|
14540
14582
|
|
|
@@ -14563,7 +14605,7 @@ lib/sql/functions/column.md
|
|
|
14563
14605
|
|
|
14564
14606
|
> **column**(`field`): `object`
|
|
14565
14607
|
|
|
14566
|
-
Defined in: [lib/sql.ts:
|
|
14608
|
+
Defined in: [lib/sql.ts:1397](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1397)
|
|
14567
14609
|
|
|
14568
14610
|
创建字段对象
|
|
14569
14611
|
|
|
@@ -14602,7 +14644,7 @@ lib/sql/functions/format.md
|
|
|
14602
14644
|
|
|
14603
14645
|
> **format**(`sql`, `data`, `service?`): `string`
|
|
14604
14646
|
|
|
14605
|
-
Defined in: [lib/sql.ts:
|
|
14647
|
+
Defined in: [lib/sql.ts:1338](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1338)
|
|
14606
14648
|
|
|
14607
14649
|
返回代入后的完整 SQL 字符串,这并不安全不能直接执行,只是用来调试打印 sql 语句
|
|
14608
14650
|
|
|
@@ -14643,7 +14685,7 @@ lib/sql/functions/get.md
|
|
|
14643
14685
|
|
|
14644
14686
|
> **get**(`opt`): [`Sql`](../classes/Sql.md)
|
|
14645
14687
|
|
|
14646
|
-
Defined in: [lib/sql.ts:
|
|
14688
|
+
Defined in: [lib/sql.ts:1310](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1310)
|
|
14647
14689
|
|
|
14648
14690
|
创建 sql 对象
|
|
14649
14691
|
|
|
@@ -14696,7 +14738,7 @@ lib/sql/functions/json.md
|
|
|
14696
14738
|
|
|
14697
14739
|
> **json**(`obj`): `any`
|
|
14698
14740
|
|
|
14699
|
-
Defined in: [lib/sql.ts:
|
|
14741
|
+
Defined in: [lib/sql.ts:1435](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1435)
|
|
14700
14742
|
|
|
14701
14743
|
将对象转换为 JSON 字符串并避开类型检查,用于适配 PostgreSQL 的 jsonb 字段
|
|
14702
14744
|
|
|
@@ -14725,7 +14767,7 @@ lib/sql/functions/value.md
|
|
|
14725
14767
|
|
|
14726
14768
|
> **value**(`val`): `object`
|
|
14727
14769
|
|
|
14728
|
-
Defined in: [lib/sql.ts:
|
|
14770
|
+
Defined in: [lib/sql.ts:1416](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1416)
|
|
14729
14771
|
|
|
14730
14772
|
创建字面量值对象,用于 where 条件中 v[0] 需要是值而非字段名的场景
|
|
14731
14773
|
例:[value('hello'), 'IN', column('tags')]
|
|
@@ -23660,7 +23702,7 @@ Defined in: [sys/mod.ts:68](https://github.com/maiyunnet/kebab/blob/master/sys/m
|
|
|
23660
23702
|
|
|
23661
23703
|
> `protected` **\_keyGenerator**(): `string`
|
|
23662
23704
|
|
|
23663
|
-
Defined in: [sys/mod.ts:
|
|
23705
|
+
Defined in: [sys/mod.ts:1776](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1776)
|
|
23664
23706
|
|
|
23665
23707
|
当 _key 不为空时,则依据继承此方法的方法自动生成填充 key
|
|
23666
23708
|
|
|
@@ -23682,7 +23724,7 @@ Defined in: [sys/mod.ts:1808](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23682
23724
|
|
|
23683
23725
|
> **all**(): `Promise`\<`false` \| [`Rows`](Rows.md)\<`Mod`\>\>
|
|
23684
23726
|
|
|
23685
|
-
Defined in: [sys/mod.ts:
|
|
23727
|
+
Defined in: [sys/mod.ts:1118](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1118)
|
|
23686
23728
|
|
|
23687
23729
|
##### Returns
|
|
23688
23730
|
|
|
@@ -23692,7 +23734,7 @@ Defined in: [sys/mod.ts:1150](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23692
23734
|
|
|
23693
23735
|
> **all**(`key`): `Promise`\<`false` \| `Record`\<`string`, `Mod`\>\>
|
|
23694
23736
|
|
|
23695
|
-
Defined in: [sys/mod.ts:
|
|
23737
|
+
Defined in: [sys/mod.ts:1119](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1119)
|
|
23696
23738
|
|
|
23697
23739
|
##### Parameters
|
|
23698
23740
|
|
|
@@ -23718,7 +23760,7 @@ Defined in: [sys/mod.ts:1151](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23718
23760
|
|
|
23719
23761
|
> **allArray**(): `Promise`\<`false` \| `Record`\<`string`, `any`\>[]\>
|
|
23720
23762
|
|
|
23721
|
-
Defined in: [sys/mod.ts:
|
|
23763
|
+
Defined in: [sys/mod.ts:1297](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1297)
|
|
23722
23764
|
|
|
23723
23765
|
##### Returns
|
|
23724
23766
|
|
|
@@ -23728,7 +23770,7 @@ Defined in: [sys/mod.ts:1329](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23728
23770
|
|
|
23729
23771
|
> **allArray**(`key`): `Promise`\<`false` \| `Record`\<`string`, `Record`\<`string`, `any`\>\>\>
|
|
23730
23772
|
|
|
23731
|
-
Defined in: [sys/mod.ts:
|
|
23773
|
+
Defined in: [sys/mod.ts:1298](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1298)
|
|
23732
23774
|
|
|
23733
23775
|
##### Parameters
|
|
23734
23776
|
|
|
@@ -23746,7 +23788,7 @@ Defined in: [sys/mod.ts:1330](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23746
23788
|
|
|
23747
23789
|
> **append**(`sql`): `this`
|
|
23748
23790
|
|
|
23749
|
-
Defined in: [sys/mod.ts:
|
|
23791
|
+
Defined in: [sys/mod.ts:1685](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1685)
|
|
23750
23792
|
|
|
23751
23793
|
在 sql 最后追加字符串
|
|
23752
23794
|
|
|
@@ -23766,7 +23808,7 @@ Defined in: [sys/mod.ts:1717](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23766
23808
|
|
|
23767
23809
|
> **by**(`c`, `d?`): `this`
|
|
23768
23810
|
|
|
23769
|
-
Defined in: [sys/mod.ts:
|
|
23811
|
+
Defined in: [sys/mod.ts:1641](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1641)
|
|
23770
23812
|
|
|
23771
23813
|
ORDER BY
|
|
23772
23814
|
|
|
@@ -23794,7 +23836,7 @@ ORDER BY
|
|
|
23794
23836
|
|
|
23795
23837
|
> **contain**(`contain`): `this`
|
|
23796
23838
|
|
|
23797
|
-
Defined in: [sys/mod.ts:
|
|
23839
|
+
Defined in: [sys/mod.ts:1694](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1694)
|
|
23798
23840
|
|
|
23799
23841
|
设置闭包含数据
|
|
23800
23842
|
|
|
@@ -23822,7 +23864,7 @@ Defined in: [sys/mod.ts:1726](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23822
23864
|
|
|
23823
23865
|
> **count**(): `Promise`\<`number`\>
|
|
23824
23866
|
|
|
23825
|
-
Defined in: [sys/mod.ts:
|
|
23867
|
+
Defined in: [sys/mod.ts:1505](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1505)
|
|
23826
23868
|
|
|
23827
23869
|
根据当前条件,筛选出当前条目该有的数据条数
|
|
23828
23870
|
|
|
@@ -23836,7 +23878,7 @@ Defined in: [sys/mod.ts:1537](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23836
23878
|
|
|
23837
23879
|
> **countSql**(): `string`
|
|
23838
23880
|
|
|
23839
|
-
Defined in: [sys/mod.ts:
|
|
23881
|
+
Defined in: [sys/mod.ts:1526](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1526)
|
|
23840
23882
|
|
|
23841
23883
|
获取当前条件下的 count 的 SQL 语句
|
|
23842
23884
|
|
|
@@ -23850,7 +23892,7 @@ Defined in: [sys/mod.ts:1558](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23850
23892
|
|
|
23851
23893
|
> **create**(): `Promise`\<`boolean` \| `null`\>
|
|
23852
23894
|
|
|
23853
|
-
Defined in: [sys/mod.ts:
|
|
23895
|
+
Defined in: [sys/mod.ts:812](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L812)
|
|
23854
23896
|
|
|
23855
23897
|
创建数据
|
|
23856
23898
|
|
|
@@ -23866,7 +23908,7 @@ true-成功,false-报错,null-唯一键非 _$key 键冲突
|
|
|
23866
23908
|
|
|
23867
23909
|
> **crossJoin**(`f`, `s`, `index?`, `pre?`): `this`
|
|
23868
23910
|
|
|
23869
|
-
Defined in: [sys/mod.ts:
|
|
23911
|
+
Defined in: [sys/mod.ts:1601](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1601)
|
|
23870
23912
|
|
|
23871
23913
|
cross join 方法
|
|
23872
23914
|
|
|
@@ -23914,7 +23956,7 @@ ON 信息
|
|
|
23914
23956
|
|
|
23915
23957
|
> **explain**(`all?`): `Promise`\<`string` \| `false`\>
|
|
23916
23958
|
|
|
23917
|
-
Defined in: [sys/mod.ts:
|
|
23959
|
+
Defined in: [sys/mod.ts:1423](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1423)
|
|
23918
23960
|
|
|
23919
23961
|
##### Parameters
|
|
23920
23962
|
|
|
@@ -23930,7 +23972,7 @@ Defined in: [sys/mod.ts:1455](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23930
23972
|
|
|
23931
23973
|
> **explain**(`all`): `Promise`\<`false` \| `Record`\<`string`, `any`\>\>
|
|
23932
23974
|
|
|
23933
|
-
Defined in: [sys/mod.ts:
|
|
23975
|
+
Defined in: [sys/mod.ts:1424](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1424)
|
|
23934
23976
|
|
|
23935
23977
|
##### Parameters
|
|
23936
23978
|
|
|
@@ -23948,7 +23990,7 @@ Defined in: [sys/mod.ts:1456](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23948
23990
|
|
|
23949
23991
|
> **filter**(`s`): `this`
|
|
23950
23992
|
|
|
23951
|
-
Defined in: [sys/mod.ts:
|
|
23993
|
+
Defined in: [sys/mod.ts:1619](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1619)
|
|
23952
23994
|
|
|
23953
23995
|
筛选器
|
|
23954
23996
|
|
|
@@ -23982,7 +24024,7 @@ Defined in: [sys/mod.ts:1651](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23982
24024
|
|
|
23983
24025
|
> **first**(`lock`, `array`): `Promise`\<`false` \| `Record`\<`string`, `any`\> \| `null`\>
|
|
23984
24026
|
|
|
23985
|
-
Defined in: [sys/mod.ts:
|
|
24027
|
+
Defined in: [sys/mod.ts:1007](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1007)
|
|
23986
24028
|
|
|
23987
24029
|
##### Parameters
|
|
23988
24030
|
|
|
@@ -24002,7 +24044,7 @@ Defined in: [sys/mod.ts:1039](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24002
24044
|
|
|
24003
24045
|
> **first**(`lock?`, `array?`): `Promise`\<`false` \| `Mod` & `Record`\<`string`, `any`\> \| `null`\>
|
|
24004
24046
|
|
|
24005
|
-
Defined in: [sys/mod.ts:
|
|
24047
|
+
Defined in: [sys/mod.ts:1011](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1011)
|
|
24006
24048
|
|
|
24007
24049
|
##### Parameters
|
|
24008
24050
|
|
|
@@ -24024,7 +24066,7 @@ Defined in: [sys/mod.ts:1043](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24024
24066
|
|
|
24025
24067
|
> **firstArray**(`lock?`): `Promise`\<`false` \| `Record`\<`string`, `any`\> \| `null`\>
|
|
24026
24068
|
|
|
24027
|
-
Defined in: [sys/mod.ts:
|
|
24069
|
+
Defined in: [sys/mod.ts:1051](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1051)
|
|
24028
24070
|
|
|
24029
24071
|
获取数据库第一个原生对象
|
|
24030
24072
|
|
|
@@ -24046,7 +24088,7 @@ Defined in: [sys/mod.ts:1083](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24046
24088
|
|
|
24047
24089
|
> **format**(`sql?`, `data?`): `string`
|
|
24048
24090
|
|
|
24049
|
-
Defined in: [sys/mod.ts:
|
|
24091
|
+
Defined in: [sys/mod.ts:1721](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1721)
|
|
24050
24092
|
|
|
24051
24093
|
获取带 data 的 sql 语句
|
|
24052
24094
|
|
|
@@ -24074,7 +24116,7 @@ sql 语句
|
|
|
24074
24116
|
|
|
24075
24117
|
> **fullJoin**(`f`, `s`, `index?`, `pre?`): `this`
|
|
24076
24118
|
|
|
24077
|
-
Defined in: [sys/mod.ts:
|
|
24119
|
+
Defined in: [sys/mod.ts:1589](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1589)
|
|
24078
24120
|
|
|
24079
24121
|
full join 方法
|
|
24080
24122
|
|
|
@@ -24114,7 +24156,7 @@ ON 信息
|
|
|
24114
24156
|
|
|
24115
24157
|
> **get**(`n`): `any`
|
|
24116
24158
|
|
|
24117
|
-
Defined in: [sys/mod.ts:
|
|
24159
|
+
Defined in: [sys/mod.ts:804](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L804)
|
|
24118
24160
|
|
|
24119
24161
|
获取一个字段值
|
|
24120
24162
|
|
|
@@ -24136,7 +24178,7 @@ Defined in: [sys/mod.ts:836](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
24136
24178
|
|
|
24137
24179
|
> **getData**(): `any`[]
|
|
24138
24180
|
|
|
24139
|
-
Defined in: [sys/mod.ts:
|
|
24181
|
+
Defined in: [sys/mod.ts:1712](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1712)
|
|
24140
24182
|
|
|
24141
24183
|
获取全部 data
|
|
24142
24184
|
|
|
@@ -24150,7 +24192,7 @@ Defined in: [sys/mod.ts:1744](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24150
24192
|
|
|
24151
24193
|
> **getSql**(): `string`
|
|
24152
24194
|
|
|
24153
|
-
Defined in: [sys/mod.ts:
|
|
24195
|
+
Defined in: [sys/mod.ts:1705](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1705)
|
|
24154
24196
|
|
|
24155
24197
|
获取 sql 语句
|
|
24156
24198
|
|
|
@@ -24164,7 +24206,7 @@ Defined in: [sys/mod.ts:1737](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24164
24206
|
|
|
24165
24207
|
> **group**(`c`): `this`
|
|
24166
24208
|
|
|
24167
|
-
Defined in: [sys/mod.ts:
|
|
24209
|
+
Defined in: [sys/mod.ts:1650](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1650)
|
|
24168
24210
|
|
|
24169
24211
|
GROUP BY
|
|
24170
24212
|
|
|
@@ -24186,7 +24228,7 @@ GROUP BY
|
|
|
24186
24228
|
|
|
24187
24229
|
> **having**(`s`): `this`
|
|
24188
24230
|
|
|
24189
|
-
Defined in: [sys/mod.ts:
|
|
24231
|
+
Defined in: [sys/mod.ts:1610](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1610)
|
|
24190
24232
|
|
|
24191
24233
|
筛选器
|
|
24192
24234
|
|
|
@@ -24208,7 +24250,7 @@ Defined in: [sys/mod.ts:1642](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24208
24250
|
|
|
24209
24251
|
> **innerJoin**(`f`, `s`, `index?`, `pre?`): `this`
|
|
24210
24252
|
|
|
24211
|
-
Defined in: [sys/mod.ts:
|
|
24253
|
+
Defined in: [sys/mod.ts:1577](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1577)
|
|
24212
24254
|
|
|
24213
24255
|
inner join 方法
|
|
24214
24256
|
|
|
@@ -24248,7 +24290,7 @@ ON 信息
|
|
|
24248
24290
|
|
|
24249
24291
|
> **join**(`f`, `s?`, `type?`, `index?`, `pre?`): `this`
|
|
24250
24292
|
|
|
24251
|
-
Defined in: [sys/mod.ts:
|
|
24293
|
+
Defined in: [sys/mod.ts:1541](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1541)
|
|
24252
24294
|
|
|
24253
24295
|
#### Parameters
|
|
24254
24296
|
|
|
@@ -24292,7 +24334,7 @@ ON 信息
|
|
|
24292
24334
|
|
|
24293
24335
|
> **langText**(`col`, `lang`): `string`
|
|
24294
24336
|
|
|
24295
|
-
Defined in: [sys/mod.ts:
|
|
24337
|
+
Defined in: [sys/mod.ts:1756](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1756)
|
|
24296
24338
|
|
|
24297
24339
|
获取字段的可用语种文本
|
|
24298
24340
|
|
|
@@ -24320,7 +24362,7 @@ Defined in: [sys/mod.ts:1788](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24320
24362
|
|
|
24321
24363
|
> **leftJoin**(`f`, `s`, `index?`, `pre?`): `this`
|
|
24322
24364
|
|
|
24323
|
-
Defined in: [sys/mod.ts:
|
|
24365
|
+
Defined in: [sys/mod.ts:1553](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1553)
|
|
24324
24366
|
|
|
24325
24367
|
left join 方法
|
|
24326
24368
|
|
|
@@ -24360,7 +24402,7 @@ ON 信息
|
|
|
24360
24402
|
|
|
24361
24403
|
> **limit**(`a`, `b?`): `this`
|
|
24362
24404
|
|
|
24363
|
-
Defined in: [sys/mod.ts:
|
|
24405
|
+
Defined in: [sys/mod.ts:1663](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1663)
|
|
24364
24406
|
|
|
24365
24407
|
LIMIT
|
|
24366
24408
|
|
|
@@ -24388,7 +24430,7 @@ LIMIT
|
|
|
24388
24430
|
|
|
24389
24431
|
> **page**(`count`, `page?`): `this`
|
|
24390
24432
|
|
|
24391
|
-
Defined in: [sys/mod.ts:
|
|
24433
|
+
Defined in: [sys/mod.ts:1674](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1674)
|
|
24392
24434
|
|
|
24393
24435
|
分页
|
|
24394
24436
|
|
|
@@ -24416,7 +24458,7 @@ Defined in: [sys/mod.ts:1706](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24416
24458
|
|
|
24417
24459
|
> **refresh**(`lock?`): `Promise`\<`boolean` \| `null`\>
|
|
24418
24460
|
|
|
24419
|
-
Defined in: [sys/mod.ts:
|
|
24461
|
+
Defined in: [sys/mod.ts:932](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L932)
|
|
24420
24462
|
|
|
24421
24463
|
刷新当前模型获取最新数据
|
|
24422
24464
|
|
|
@@ -24438,7 +24480,7 @@ Defined in: [sys/mod.ts:964](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
24438
24480
|
|
|
24439
24481
|
> **remove**(): `Promise`\<`boolean`\>
|
|
24440
24482
|
|
|
24441
|
-
Defined in: [sys/mod.ts:
|
|
24483
|
+
Defined in: [sys/mod.ts:989](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L989)
|
|
24442
24484
|
|
|
24443
24485
|
移除本条目
|
|
24444
24486
|
|
|
@@ -24452,7 +24494,7 @@ Defined in: [sys/mod.ts:1021](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24452
24494
|
|
|
24453
24495
|
> **rightJoin**(`f`, `s`, `index?`, `pre?`): `this`
|
|
24454
24496
|
|
|
24455
|
-
Defined in: [sys/mod.ts:
|
|
24497
|
+
Defined in: [sys/mod.ts:1565](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1565)
|
|
24456
24498
|
|
|
24457
24499
|
right join 方法
|
|
24458
24500
|
|
|
@@ -24492,7 +24534,7 @@ ON 信息
|
|
|
24492
24534
|
|
|
24493
24535
|
> **save**(`where?`): `Promise`\<`boolean`\>
|
|
24494
24536
|
|
|
24495
|
-
Defined in: [sys/mod.ts:
|
|
24537
|
+
Defined in: [sys/mod.ts:960](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L960)
|
|
24496
24538
|
|
|
24497
24539
|
更新 set 的数据到数据库,有未保存数据时才保存
|
|
24498
24540
|
|
|
@@ -24526,7 +24568,7 @@ Defined in: [sys/mod.ts:992](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
24526
24568
|
|
|
24527
24569
|
> **set**\<`T`, `TK`\>(`n`): `void`
|
|
24528
24570
|
|
|
24529
|
-
Defined in: [sys/mod.ts:
|
|
24571
|
+
Defined in: [sys/mod.ts:765](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L765)
|
|
24530
24572
|
|
|
24531
24573
|
##### Type Parameters
|
|
24532
24574
|
|
|
@@ -24552,7 +24594,7 @@ Defined in: [sys/mod.ts:797](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
24552
24594
|
|
|
24553
24595
|
> **set**\<`T`, `TK`\>(`n`, `v`): `void`
|
|
24554
24596
|
|
|
24555
|
-
Defined in: [sys/mod.ts:
|
|
24597
|
+
Defined in: [sys/mod.ts:766](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L766)
|
|
24556
24598
|
|
|
24557
24599
|
##### Type Parameters
|
|
24558
24600
|
|
|
@@ -24584,7 +24626,7 @@ Defined in: [sys/mod.ts:798](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
24584
24626
|
|
|
24585
24627
|
> **toArray**\<`TC`\>(): [`TOnlyProperties`](../type-aliases/TOnlyProperties.md)\<`InstanceType`\<`TC`\>\> & `Record`\<`string`, `any`\>
|
|
24586
24628
|
|
|
24587
|
-
Defined in: [sys/mod.ts:
|
|
24629
|
+
Defined in: [sys/mod.ts:1728](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1728)
|
|
24588
24630
|
|
|
24589
24631
|
获取值对象,获取的是新创建的数组
|
|
24590
24632
|
|
|
@@ -24604,7 +24646,7 @@ Defined in: [sys/mod.ts:1760](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24604
24646
|
|
|
24605
24647
|
> **total**(`f?`): `Promise`\<`number`\>
|
|
24606
24648
|
|
|
24607
|
-
Defined in: [sys/mod.ts:
|
|
24649
|
+
Defined in: [sys/mod.ts:1481](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1481)
|
|
24608
24650
|
|
|
24609
24651
|
获取总条数,自动抛弃 LIMIT,仅用于获取数据的情况(select)
|
|
24610
24652
|
|
|
@@ -24624,7 +24666,7 @@ Defined in: [sys/mod.ts:1513](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24624
24666
|
|
|
24625
24667
|
> **union**(`f`, `type?`): `this`
|
|
24626
24668
|
|
|
24627
|
-
Defined in: [sys/mod.ts:
|
|
24669
|
+
Defined in: [sys/mod.ts:1062](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1062)
|
|
24628
24670
|
|
|
24629
24671
|
联合查询表数据
|
|
24630
24672
|
|
|
@@ -24652,7 +24694,7 @@ Defined in: [sys/mod.ts:1094](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24652
24694
|
|
|
24653
24695
|
> **unionAll**(`f`): `this`
|
|
24654
24696
|
|
|
24655
|
-
Defined in: [sys/mod.ts:
|
|
24697
|
+
Defined in: [sys/mod.ts:1092](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1092)
|
|
24656
24698
|
|
|
24657
24699
|
所有联合查询表数据
|
|
24658
24700
|
|
|
@@ -24674,7 +24716,7 @@ Defined in: [sys/mod.ts:1124](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24674
24716
|
|
|
24675
24717
|
> **unsaved**(): `boolean`
|
|
24676
24718
|
|
|
24677
|
-
Defined in: [sys/mod.ts:
|
|
24719
|
+
Defined in: [sys/mod.ts:1747](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1747)
|
|
24678
24720
|
|
|
24679
24721
|
当前是否设置了未保存 --=
|
|
24680
24722
|
|
|
@@ -24688,7 +24730,7 @@ Defined in: [sys/mod.ts:1779](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24688
24730
|
|
|
24689
24731
|
> **updates**(): `Record`\<`string`, `any`\>
|
|
24690
24732
|
|
|
24691
|
-
Defined in: [sys/mod.ts:
|
|
24733
|
+
Defined in: [sys/mod.ts:1736](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1736)
|
|
24692
24734
|
|
|
24693
24735
|
获取当前设置要提交的数据
|
|
24694
24736
|
|
|
@@ -24702,7 +24744,7 @@ Defined in: [sys/mod.ts:1768](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24702
24744
|
|
|
24703
24745
|
> **upsert**(`conflict`): `Promise`\<`boolean`\>
|
|
24704
24746
|
|
|
24705
|
-
Defined in: [sys/mod.ts:
|
|
24747
|
+
Defined in: [sys/mod.ts:902](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L902)
|
|
24706
24748
|
|
|
24707
24749
|
插入数据,如果存在则更新(UPSERT)
|
|
24708
24750
|
|
|
@@ -24724,7 +24766,7 @@ Defined in: [sys/mod.ts:934](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
24724
24766
|
|
|
24725
24767
|
> **where**(`s`): `this`
|
|
24726
24768
|
|
|
24727
|
-
Defined in: [sys/mod.ts:
|
|
24769
|
+
Defined in: [sys/mod.ts:1630](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1630)
|
|
24728
24770
|
|
|
24729
24771
|
是 filter 的别名
|
|
24730
24772
|
|
|
@@ -24778,7 +24820,7 @@ Defined in: [sys/mod.ts:175](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
24778
24820
|
|
|
24779
24821
|
> `static` **find**\<`T`\>(`db`, `val`, `opt?`): `Promise`\<`false` \| `T` & `Record`\<`string`, `any`\> \| `null`\>
|
|
24780
24822
|
|
|
24781
|
-
Defined in: [sys/mod.ts:
|
|
24823
|
+
Defined in: [sys/mod.ts:588](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L588)
|
|
24782
24824
|
|
|
24783
24825
|
根据主键(或 key 字段)获取对象
|
|
24784
24826
|
|
|
@@ -24838,7 +24880,7 @@ Defined in: [sys/mod.ts:620](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
24838
24880
|
|
|
24839
24881
|
> `static` **getCreate**\<`T`\>(`db`, `opt?`): `T`
|
|
24840
24882
|
|
|
24841
|
-
Defined in: [sys/mod.ts:
|
|
24883
|
+
Defined in: [sys/mod.ts:570](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L570)
|
|
24842
24884
|
|
|
24843
24885
|
获取创建对象,通常用于新建数据库条目
|
|
24844
24886
|
|
|
@@ -25026,7 +25068,7 @@ Defined in: [sys/mod.ts:193](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
25026
25068
|
|
|
25027
25069
|
> `static` **one**(`db`, `s`, `opt`): `Promise`\<`false` \| `Record`\<`string`, `any`\> \| `null`\>
|
|
25028
25070
|
|
|
25029
|
-
Defined in: [sys/mod.ts:
|
|
25071
|
+
Defined in: [sys/mod.ts:615](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L615)
|
|
25030
25072
|
|
|
25031
25073
|
##### Parameters
|
|
25032
25074
|
|
|
@@ -25076,7 +25118,7 @@ Defined in: [sys/mod.ts:647](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
25076
25118
|
|
|
25077
25119
|
> `static` **one**\<`T`\>(`db`, `s`, `opt?`): `Promise`\<`false` \| `T` & `Record`\<`string`, `any`\> \| `null`\>
|
|
25078
25120
|
|
|
25079
|
-
Defined in: [sys/mod.ts:
|
|
25121
|
+
Defined in: [sys/mod.ts:628](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L628)
|
|
25080
25122
|
|
|
25081
25123
|
##### Type Parameters
|
|
25082
25124
|
|
|
@@ -25134,7 +25176,7 @@ Defined in: [sys/mod.ts:660](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
25134
25176
|
|
|
25135
25177
|
> `static` **oneArray**(`db`, `s`, `opt?`): `Promise`\<`false` \| `Record`\<`string`, `any`\> \| `null`\>
|
|
25136
25178
|
|
|
25137
|
-
Defined in: [sys/mod.ts:
|
|
25179
|
+
Defined in: [sys/mod.ts:705](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L705)
|
|
25138
25180
|
|
|
25139
25181
|
通过 where 条件筛选单条数据返回原生对象
|
|
25140
25182
|
|
|
@@ -25186,7 +25228,7 @@ Defined in: [sys/mod.ts:737](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
25186
25228
|
|
|
25187
25229
|
> `static` **primarys**(`db`, `where?`, `opt?`): `Promise`\<`false` \| `any`[]\>
|
|
25188
25230
|
|
|
25189
|
-
Defined in: [sys/mod.ts:
|
|
25231
|
+
Defined in: [sys/mod.ts:726](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L726)
|
|
25190
25232
|
|
|
25191
25233
|
根据 where 条件获取主键值列表
|
|
25192
25234
|
|
|
@@ -25334,7 +25376,7 @@ Defined in: [sys/mod.ts:334](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
25334
25376
|
|
|
25335
25377
|
> `static` **select**\<`T`\>(`db`, `c`, `opt?`): `T` & `Record`\<`string`, `any`\>
|
|
25336
25378
|
|
|
25337
|
-
Defined in: [sys/mod.ts:
|
|
25379
|
+
Defined in: [sys/mod.ts:511](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L511)
|
|
25338
25380
|
|
|
25339
25381
|
select 自定字段
|
|
25340
25382
|
|
|
@@ -25400,7 +25442,7 @@ select 自定字段
|
|
|
25400
25442
|
|
|
25401
25443
|
> `static` **toArrayByRecord**\<`T`\>(`obj`): `Record`\<`string`, `Record`\<`string`, `any`\>\>
|
|
25402
25444
|
|
|
25403
|
-
Defined in: [sys/mod.ts:
|
|
25445
|
+
Defined in: [sys/mod.ts:753](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L753)
|
|
25404
25446
|
|
|
25405
25447
|
将 key val 组成的数据列表转换为原生对象模式,获取的是新创建的数组
|
|
25406
25448
|
|
|
@@ -25626,7 +25668,7 @@ Defined in: [sys/mod.ts:184](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
25626
25668
|
|
|
25627
25669
|
> `static` **where**\<`T`\>(`db`, `s?`, `opt?`): `T` & `Record`\<`string`, `any`\>
|
|
25628
25670
|
|
|
25629
|
-
Defined in: [sys/mod.ts:
|
|
25671
|
+
Defined in: [sys/mod.ts:541](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L541)
|
|
25630
25672
|
|
|
25631
25673
|
通过 where 条件获取模型
|
|
25632
25674
|
|
|
@@ -25891,7 +25933,7 @@ sys/mod/interfaces/IModUnionItem.md
|
|
|
25891
25933
|
|
|
25892
25934
|
# Interface: IModUnionItem
|
|
25893
25935
|
|
|
25894
|
-
Defined in: [sys/mod.ts:
|
|
25936
|
+
Defined in: [sys/mod.ts:1790](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1790)
|
|
25895
25937
|
|
|
25896
25938
|
## Properties
|
|
25897
25939
|
|
|
@@ -25899,7 +25941,7 @@ Defined in: [sys/mod.ts:1822](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
25899
25941
|
|
|
25900
25942
|
> **field**: `string`
|
|
25901
25943
|
|
|
25902
|
-
Defined in: [sys/mod.ts:
|
|
25944
|
+
Defined in: [sys/mod.ts:1791](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1791)
|
|
25903
25945
|
|
|
25904
25946
|
***
|
|
25905
25947
|
|
|
@@ -25907,7 +25949,7 @@ Defined in: [sys/mod.ts:1823](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
25907
25949
|
|
|
25908
25950
|
> `optional` **where?**: `any`
|
|
25909
25951
|
|
|
25910
|
-
Defined in: [sys/mod.ts:
|
|
25952
|
+
Defined in: [sys/mod.ts:1792](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1792)
|
|
25911
25953
|
|
|
25912
25954
|
sys/mod/interfaces/IRows.md
|
|
25913
25955
|
---
|
|
@@ -25920,7 +25962,7 @@ sys/mod/interfaces/IRows.md
|
|
|
25920
25962
|
|
|
25921
25963
|
# Interface: IRows\<T\>
|
|
25922
25964
|
|
|
25923
|
-
Defined in: [sys/mod.ts:
|
|
25965
|
+
Defined in: [sys/mod.ts:1784](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1784)
|
|
25924
25966
|
|
|
25925
25967
|
## Extends
|
|
25926
25968
|
|
|
@@ -25938,7 +25980,7 @@ Defined in: [sys/mod.ts:1816](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
25938
25980
|
|
|
25939
25981
|
> `readonly` **length**: `number`
|
|
25940
25982
|
|
|
25941
|
-
Defined in: [sys/mod.ts:
|
|
25983
|
+
Defined in: [sys/mod.ts:1785](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1785)
|
|
25942
25984
|
|
|
25943
25985
|
## Methods
|
|
25944
25986
|
|
|
@@ -25946,7 +25988,7 @@ Defined in: [sys/mod.ts:1817](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
25946
25988
|
|
|
25947
25989
|
> **item**(`index`): `T`
|
|
25948
25990
|
|
|
25949
|
-
Defined in: [sys/mod.ts:
|
|
25991
|
+
Defined in: [sys/mod.ts:1786](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1786)
|
|
25950
25992
|
|
|
25951
25993
|
#### Parameters
|
|
25952
25994
|
|
|
@@ -25964,7 +26006,7 @@ Defined in: [sys/mod.ts:1818](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
25964
26006
|
|
|
25965
26007
|
> **toArray**(): `Record`\<`string`, `any`\>[]
|
|
25966
26008
|
|
|
25967
|
-
Defined in: [sys/mod.ts:
|
|
26009
|
+
Defined in: [sys/mod.ts:1787](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1787)
|
|
25968
26010
|
|
|
25969
26011
|
#### Returns
|
|
25970
26012
|
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
7
7
|
*/
|
|
8
8
|
/** --- 当前系统版本号 --- */
|
|
9
|
-
export const VER = '9.
|
|
9
|
+
export const VER = '9.5.0';
|
|
10
10
|
// --- 服务端用的路径 ---
|
|
11
11
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
12
12
|
/** --- /xxx/xxx --- */
|
package/lib/core.d.ts
CHANGED
|
@@ -268,7 +268,7 @@ export declare function getLog(opt: {
|
|
|
268
268
|
'limit'?: number;
|
|
269
269
|
/** --- 获取局域网服务器的日志,为空代表获取本机的 --- */
|
|
270
270
|
'host'?: string;
|
|
271
|
-
}): Promise<string[][] | null | false>;
|
|
271
|
+
}): Promise<string[][] | kebab.Json[] | null | false>;
|
|
272
272
|
/**
|
|
273
273
|
* --- 获取目录内文件/文件夹列表 ---
|
|
274
274
|
* @param opt 参数
|
package/lib/sql.d.ts
CHANGED
|
@@ -69,6 +69,16 @@ export declare class Sql {
|
|
|
69
69
|
* @param conflict 冲突字段,PostgreSQL 用于指定 ON CONFLICT 字段;MySQL 时忽略,因为会对所有唯一键冲突执行更新
|
|
70
70
|
*/
|
|
71
71
|
upsert(data: kebab.Json, conflict?: string | string[]): this;
|
|
72
|
+
/**
|
|
73
|
+
* --- 批量 UPDATE,以子查询作为数据源,纯更新语义(不会插入新行)---
|
|
74
|
+
* --- MySQL: UPDATE t INNER JOIN (SELECT col AS alias ... UNION ALL SELECT ...) AS tmp ON t.key=tmp.key SET t.c=tmp.c ---
|
|
75
|
+
* --- PostgreSQL: UPDATE t SET c=tmp.c FROM (VALUES ($1,...)) AS tmp(cols) WHERE t.key=tmp.key ---
|
|
76
|
+
* @param table 表名
|
|
77
|
+
* @param key 用于定位的主键/唯一键字段名
|
|
78
|
+
* @param cols 要更新的列名数组(不含 key)
|
|
79
|
+
* @param rows 数据行数组,每行顺序为 [keyVal, col1Val, col2Val, ...](与 [key, ...cols] 对应)
|
|
80
|
+
*/
|
|
81
|
+
updateByValues(table: string, key: string, cols: string[], rows: any[][]): this;
|
|
72
82
|
/**
|
|
73
83
|
* --- '*', 'xx' ---
|
|
74
84
|
* @param c 字段字符串或字段数组
|
|
@@ -237,6 +247,11 @@ export declare class Sql {
|
|
|
237
247
|
private _isValue;
|
|
238
248
|
/** --- 获取占位符 --- */
|
|
239
249
|
private _placeholder;
|
|
250
|
+
/**
|
|
251
|
+
* --- 返回 PostgreSQL VALUES 第一行的显式类型转换后缀,用于帮助 PostgreSQL 推断 VALUES 派生表列类型 ---
|
|
252
|
+
* @param v 要处理的值
|
|
253
|
+
*/
|
|
254
|
+
private _pgCastSuffix;
|
|
240
255
|
/**
|
|
241
256
|
* --- 处理单个值,检测数据类型并返回 SQL 和 data ---
|
|
242
257
|
* @param v 要处理的值
|
package/lib/sql.js
CHANGED
|
@@ -166,6 +166,59 @@ export class Sql {
|
|
|
166
166
|
}
|
|
167
167
|
return this;
|
|
168
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* --- 批量 UPDATE,以子查询作为数据源,纯更新语义(不会插入新行)---
|
|
171
|
+
* --- MySQL: UPDATE t INNER JOIN (SELECT col AS alias ... UNION ALL SELECT ...) AS tmp ON t.key=tmp.key SET t.c=tmp.c ---
|
|
172
|
+
* --- PostgreSQL: UPDATE t SET c=tmp.c FROM (VALUES ($1,...)) AS tmp(cols) WHERE t.key=tmp.key ---
|
|
173
|
+
* @param table 表名
|
|
174
|
+
* @param key 用于定位的主键/唯一键字段名
|
|
175
|
+
* @param cols 要更新的列名数组(不含 key)
|
|
176
|
+
* @param rows 数据行数组,每行顺序为 [keyVal, col1Val, col2Val, ...](与 [key, ...cols] 对应)
|
|
177
|
+
*/
|
|
178
|
+
updateByValues(table, key, cols, rows) {
|
|
179
|
+
this._data = [];
|
|
180
|
+
this._placeholderCounter = 1;
|
|
181
|
+
const allCols = [key, ...cols];
|
|
182
|
+
const quotedTable = this.field(table, this._pre);
|
|
183
|
+
const quotedKey = this.field(key);
|
|
184
|
+
if (this._service === ESERVICE.MYSQL) {
|
|
185
|
+
// --- MySQL 8.0.19+ VALUES ROW() 派生表语法 ---
|
|
186
|
+
const valueParts = [];
|
|
187
|
+
for (const row of rows) {
|
|
188
|
+
const parts = row.map(v => {
|
|
189
|
+
const result = this._processValue(v);
|
|
190
|
+
if (result.data.length > 0) {
|
|
191
|
+
this._data.push(...result.data);
|
|
192
|
+
}
|
|
193
|
+
return result.sql;
|
|
194
|
+
});
|
|
195
|
+
valueParts.push(`ROW(${parts.join(', ')})`);
|
|
196
|
+
}
|
|
197
|
+
const tmpCols = allCols.map(c => this.field(c)).join(', ');
|
|
198
|
+
const setClauses = cols.map(c => `t.${this.field(c)} = tmp.${this.field(c)}`).join(', ');
|
|
199
|
+
this._sql = [`UPDATE ${quotedTable} t INNER JOIN (VALUES ${valueParts.join(', ')}) AS tmp(${tmpCols}) ON t.${quotedKey} = tmp.${quotedKey} SET ${setClauses}`];
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
// --- PostgreSQL 使用 UPDATE FROM (VALUES ...) ---
|
|
203
|
+
const valueParts = [];
|
|
204
|
+
for (let ri = 0; ri < rows.length; ri++) {
|
|
205
|
+
const row = rows[ri];
|
|
206
|
+
const parts = row.map(v => {
|
|
207
|
+
const result = this._processValue(v);
|
|
208
|
+
if (result.data.length > 0) {
|
|
209
|
+
this._data.push(...result.data);
|
|
210
|
+
}
|
|
211
|
+
// --- 第一行加显式类型转换,帮助 PostgreSQL 推断 VALUES 派生表的列类型 ---
|
|
212
|
+
return ri === 0 ? result.sql + this._pgCastSuffix(v) : result.sql;
|
|
213
|
+
});
|
|
214
|
+
valueParts.push(`(${parts.join(', ')})`);
|
|
215
|
+
}
|
|
216
|
+
const tmpCols = allCols.map(c => this.field(c)).join(', ');
|
|
217
|
+
const setClauses = cols.map(c => `${this.field(c)} = tmp.${this.field(c)}`).join(', ');
|
|
218
|
+
this._sql = [`UPDATE ${quotedTable} t SET ${setClauses} FROM (VALUES ${valueParts.join(', ')}) AS tmp(${tmpCols}) WHERE t.${quotedKey} = tmp.${quotedKey}`];
|
|
219
|
+
}
|
|
220
|
+
return this;
|
|
221
|
+
}
|
|
169
222
|
/**
|
|
170
223
|
* --- '*', 'xx' ---
|
|
171
224
|
* @param c 字段字符串或字段数组
|
|
@@ -984,6 +1037,48 @@ export class Sql {
|
|
|
984
1037
|
_placeholder() {
|
|
985
1038
|
return this._service === ESERVICE.MYSQL ? '?' : `$${this._placeholderCounter++}`;
|
|
986
1039
|
}
|
|
1040
|
+
/**
|
|
1041
|
+
* --- 返回 PostgreSQL VALUES 第一行的显式类型转换后缀,用于帮助 PostgreSQL 推断 VALUES 派生表列类型 ---
|
|
1042
|
+
* @param v 要处理的值
|
|
1043
|
+
*/
|
|
1044
|
+
_pgCastSuffix(v) {
|
|
1045
|
+
if (v === null || v === undefined) {
|
|
1046
|
+
return '';
|
|
1047
|
+
}
|
|
1048
|
+
if (typeof v === 'number') {
|
|
1049
|
+
return Number.isInteger(v) ? '::bigint' : '::float8';
|
|
1050
|
+
}
|
|
1051
|
+
if (typeof v === 'boolean') {
|
|
1052
|
+
return '::boolean';
|
|
1053
|
+
}
|
|
1054
|
+
if (v instanceof Buffer) {
|
|
1055
|
+
return '::bytea';
|
|
1056
|
+
}
|
|
1057
|
+
if (Array.isArray(v)) {
|
|
1058
|
+
// --- 函数式语法 ['FUNC(?)', [...]],不加转换 ---
|
|
1059
|
+
if (typeof v[0] === 'string' && v[0].includes('(')) {
|
|
1060
|
+
return '';
|
|
1061
|
+
}
|
|
1062
|
+
// --- POLYGON ---
|
|
1063
|
+
if (v[0]?.y !== undefined) {
|
|
1064
|
+
return '::polygon';
|
|
1065
|
+
}
|
|
1066
|
+
// --- JSON 数组或 PG 原生数组(text[]、int[] 等),
|
|
1067
|
+
// 不加转换,由 pg 驱动与目标列类型决定 ---
|
|
1068
|
+
return '';
|
|
1069
|
+
}
|
|
1070
|
+
if (typeof v === 'object') {
|
|
1071
|
+
// --- POINT ---
|
|
1072
|
+
if (v.y !== undefined) {
|
|
1073
|
+
return '::point';
|
|
1074
|
+
}
|
|
1075
|
+
// --- JSON 对象(用户应通过 sql.json() 包裹为字符串后传入),不加转换 ---
|
|
1076
|
+
return '';
|
|
1077
|
+
}
|
|
1078
|
+
// --- string:保持 unknown 类型,兼容 text/varchar/jsonb 等目标列类型;
|
|
1079
|
+
// 使用 sql.json() 包裹的 jsonb 数据经此路径,unknown 可隐式 cast 到 jsonb ---
|
|
1080
|
+
return '';
|
|
1081
|
+
}
|
|
987
1082
|
/**
|
|
988
1083
|
* --- 处理单个值,检测数据类型并返回 SQL 和 data ---
|
|
989
1084
|
* @param v 要处理的值
|
package/lib/undici/response.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare class Response {
|
|
|
31
31
|
/**
|
|
32
32
|
* --- 获取响应读取流对象 ---
|
|
33
33
|
*/
|
|
34
|
-
getStream():
|
|
34
|
+
getStream(): (import("undici/types/readable").default & undici.Dispatcher.BodyMixin) | zlib.Gunzip | zlib.Inflate | zlib.BrotliDecompress | null;
|
|
35
35
|
/**
|
|
36
36
|
* --- 获取原生响应读取流对象 ---
|
|
37
37
|
*/
|
package/package.json
CHANGED
package/sys/master.js
CHANGED
|
@@ -523,9 +523,15 @@ function createRpcListener() {
|
|
|
523
523
|
let limit = msg.limit ?? 100;
|
|
524
524
|
/** --- 剩余 offset --- */
|
|
525
525
|
let offset = msg.offset ?? 0;
|
|
526
|
+
/**
|
|
527
|
+
* --- csv 格式:string[][] 每行是字段数组,顺序与表头一致 ---
|
|
528
|
+
* --- [['H:i:s', unix, url, cookie, session, userAgent, realIp, cfIp, xIp, osMem, procMem, message], ...] ---
|
|
529
|
+
* --- jsonl 格式:object[] 每行是解析后的 JSON 对象 ---
|
|
530
|
+
* --- [{ time, unix, url, cookie, session, userAgent, realIp, cfIp, xIp, osMem, procMem, message }, ...] ---
|
|
531
|
+
*/
|
|
526
532
|
const rtn = await new Promise(resolve => {
|
|
527
533
|
const list = [];
|
|
528
|
-
/** ---
|
|
534
|
+
/** --- 当前行号(jsonl 无表头,csv 有表头,两者处理逻辑不同)--- */
|
|
529
535
|
let line = 0;
|
|
530
536
|
/** --- 当前行数据 --- */
|
|
531
537
|
let packet = '';
|
|
@@ -552,34 +558,44 @@ function createRpcListener() {
|
|
|
552
558
|
buf = buf.slice(index + 1);
|
|
553
559
|
++line;
|
|
554
560
|
// --- 先执行下本次完成的 ---
|
|
555
|
-
|
|
561
|
+
// --- csv:line > 1 跳过表头行;jsonl:无表头,line >= 1 即可处理 ---
|
|
562
|
+
if (format === 'jsonl' ? line >= 1 : line > 1) {
|
|
556
563
|
if (offset === 0) {
|
|
557
564
|
if (!msg.search || packet.includes(msg.search)) {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
565
|
+
if (format === 'jsonl') {
|
|
566
|
+
const obj = lText.parseJson(packet);
|
|
567
|
+
if (obj) {
|
|
568
|
+
list.push(obj);
|
|
569
|
+
--limit;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
const result = [];
|
|
574
|
+
let currentField = '';
|
|
575
|
+
let inQuotes = false;
|
|
576
|
+
for (let i = 0; i < packet.length; ++i) {
|
|
577
|
+
const char = packet[i];
|
|
578
|
+
if (char === '"') {
|
|
579
|
+
if (inQuotes && packet[i + 1] === '"') {
|
|
580
|
+
currentField += '"';
|
|
581
|
+
++i;
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
inQuotes = !inQuotes;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
else if (char === ',' && !inQuotes) {
|
|
588
|
+
result.push(currentField);
|
|
589
|
+
currentField = '';
|
|
567
590
|
}
|
|
568
591
|
else {
|
|
569
|
-
|
|
592
|
+
currentField += char;
|
|
570
593
|
}
|
|
571
594
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
}
|
|
576
|
-
else {
|
|
577
|
-
currentField += char;
|
|
578
|
-
}
|
|
595
|
+
result.push(currentField);
|
|
596
|
+
list.push(result);
|
|
597
|
+
--limit;
|
|
579
598
|
}
|
|
580
|
-
result.push(currentField);
|
|
581
|
-
list.push(result);
|
|
582
|
-
--limit;
|
|
583
599
|
}
|
|
584
600
|
}
|
|
585
601
|
else {
|
package/sys/mod.js
CHANGED
|
@@ -313,66 +313,43 @@ export default class Mod {
|
|
|
313
313
|
if (!data.length) {
|
|
314
314
|
return true;
|
|
315
315
|
}
|
|
316
|
-
// ---
|
|
317
|
-
const
|
|
316
|
+
// --- 按列集合分组(处理稀疏数据,保证每组内所有行的列完全一致)---
|
|
317
|
+
const groups = new Map();
|
|
318
318
|
for (const item of data) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
319
|
+
const itemCols = Object.keys(item).filter(k => k !== key).sort();
|
|
320
|
+
if (itemCols.length === 0) {
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
const groupKey = itemCols.join('\0');
|
|
324
|
+
if (!groups.has(groupKey)) {
|
|
325
|
+
groups.set(groupKey, []);
|
|
323
326
|
}
|
|
327
|
+
groups.get(groupKey).push(item);
|
|
324
328
|
}
|
|
325
|
-
if (
|
|
329
|
+
if (groups.size === 0) {
|
|
326
330
|
return true;
|
|
327
331
|
}
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
let caseSql = `(CASE ${sq.field(key)}`;
|
|
348
|
-
const params = [];
|
|
349
|
-
let hasUpdate = false;
|
|
350
|
-
for (const item of batch) {
|
|
351
|
-
if (item[col] !== undefined) {
|
|
352
|
-
caseSql += ` WHEN ? THEN ?`;
|
|
353
|
-
params.push(item[key], item[col]);
|
|
354
|
-
hasUpdate = true;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
if (hasUpdate) {
|
|
358
|
-
caseSql += ` ELSE ${sq.field(col)} END)`;
|
|
359
|
-
updates[col] = [caseSql, params];
|
|
332
|
+
const tableName = this._$table + (opt.index ? ('_' + opt.index) : '');
|
|
333
|
+
for (const [, groupItems] of groups) {
|
|
334
|
+
const cols = Object.keys(groupItems[0]).filter(k => k !== key).sort();
|
|
335
|
+
const allCols = [key, ...cols];
|
|
336
|
+
// --- 每行占位符数量 = key + 所有列,分批避免超出数据库参数上限 ---
|
|
337
|
+
const batchSize = Math.floor(60000 / allCols.length);
|
|
338
|
+
for (let i = 0; i < groupItems.length; i += batchSize) {
|
|
339
|
+
const batch = groupItems.slice(i, i + batchSize);
|
|
340
|
+
const sq = lSql.get({
|
|
341
|
+
'service': db.getService() ?? lDb.ESERVICE.PGSQL,
|
|
342
|
+
'ctr': opt.ctr,
|
|
343
|
+
'pre': opt.pre ?? this._$pre,
|
|
344
|
+
});
|
|
345
|
+
const rows = batch.map(item => allCols.map(c => item[c] ?? null));
|
|
346
|
+
sq.updateByValues(tableName, key, cols, rows);
|
|
347
|
+
const r = await db.execute(sq.getSql(), sq.getData());
|
|
348
|
+
if (r.packet === null) {
|
|
349
|
+
lCore.log(opt.ctr ?? {}, '[MOD][updateList] ' + (lText.stringifyJson(r.error?.message ?? '').slice(1, -1) + ' - ' + sq.format()).replaceAll('"', '""'), '-error');
|
|
350
|
+
return false;
|
|
360
351
|
}
|
|
361
352
|
}
|
|
362
|
-
// --- 收集 keys ---
|
|
363
|
-
for (const item of batch) {
|
|
364
|
-
keys.push(item[key]);
|
|
365
|
-
}
|
|
366
|
-
if (Object.keys(updates).length === 0) {
|
|
367
|
-
continue;
|
|
368
|
-
}
|
|
369
|
-
sq.update(this._$table + (opt.index ? ('_' + opt.index) : ''), updates)
|
|
370
|
-
.where({ [key]: keys });
|
|
371
|
-
const r = await db.execute(sq.getSql(), sq.getData());
|
|
372
|
-
if (r.packet === null) {
|
|
373
|
-
lCore.log(opt.ctr ?? {}, '[MOD][updateList] ' + (lText.stringifyJson(r.error?.message ?? '').slice(1, -1) + ' - ' + sq.format()).replaceAll('"', '""'), '-error');
|
|
374
|
-
return false;
|
|
375
|
-
}
|
|
376
353
|
}
|
|
377
354
|
return true;
|
|
378
355
|
}
|
package/www/example/ctr/test.js
CHANGED
|
@@ -1395,11 +1395,21 @@ for (let i = 0; i < 30000; ++i) {
|
|
|
1395
1395
|
const echo = [];
|
|
1396
1396
|
echo.push('<table style="width: 100%;">');
|
|
1397
1397
|
if (list) {
|
|
1398
|
-
echo.push('<tr><th>TIME</th><th>UNIX</th><th>URL</th><th>COOKIE</th><th>SESSION</th><th>USER_AGENT</th><th>REALIP</th><th>
|
|
1398
|
+
echo.push('<tr><th>TIME</th><th>UNIX</th><th>URL</th><th>COOKIE</th><th>SESSION</th><th>USER_AGENT</th><th>REALIP</th><th>CFIP</th><th>XIP</th><th>OS</th><th>PROCESS</th><th>MESSAGE</th></tr>');
|
|
1399
1399
|
for (const row of list) {
|
|
1400
1400
|
echo.push('<tr>');
|
|
1401
|
-
|
|
1402
|
-
|
|
1401
|
+
if (Array.isArray(row)) {
|
|
1402
|
+
// --- csv 格式:string[] ---
|
|
1403
|
+
for (const item of row) {
|
|
1404
|
+
echo.push('<td>' + lText.htmlescape(item) + '</td>');
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
else {
|
|
1408
|
+
// --- jsonl 格式:object ---
|
|
1409
|
+
const r = row;
|
|
1410
|
+
for (const val of [r.time, r.unix, r.url, r.cookie, r.session, r.userAgent, r.realIp, r.cfIp, r.xIp, r.osMem, r.procMem, r.message]) {
|
|
1411
|
+
echo.push('<td>' + lText.htmlescape(typeof val === 'string' ? val : lText.stringifyJson(val) ?? '') + '</td>');
|
|
1412
|
+
}
|
|
1403
1413
|
}
|
|
1404
1414
|
echo.push('</tr>');
|
|
1405
1415
|
}
|