@maiyunnet/kebab 9.27.0 → 9.27.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/doc/kebab-rag.md CHANGED
@@ -210,6 +210,29 @@ public create(): kebab.Json[] {
210
210
 
211
211
  `_valibotx` 默认先校验 `_xsrf`,通过后才运行 schema,且 `_xsrf` 不会被自动加入 schema 输出。仅在已有等效安全机制时才可使用 `{ 'ignoreXsrf': true }`。只读请求使用 `_valibot`。
212
212
 
213
+
214
+ ## 原生分区表模型
215
+
216
+ 模型通过 `_$partition` 声明数据库原生分区字段,RANGE、HASH、LIST 采用相同写法;支持多个字段。数据库仍负责根据字段值选择分区,框架不查询分区目录,也不自动创建分区。
217
+
218
+ ```ts
219
+ export default class Order extends sMod {
220
+ protected static _$table = 'order';
221
+ protected static _$primary = 'id';
222
+ protected static _$partition = ['time_push'];
223
+ }
224
+ ```
225
+
226
+ 读取模型后,`save()`、`remove()`、`refresh()` 的默认条件自动包含主键与分区字段。例如上面的模型使用 `id = ? AND time_push = ?`。`set()` 仍用于指定待写数据,调用方不必反复填写分区条件。
227
+
228
+ - 查询时须选出主键及全部分区字段。读取记录后不要修改这些字段,包括通过 `set()` 赋值或直接修改 Date、Buffer 等对象;框架直接使用模型中的当前值构造 WHERE,不保存旧值,也不检查这些字段是否被改动。
229
+ - 创建记录时设置分区字段,主键使用数据库返回的自增 ID;使用数据库默认值、生成列、触发器或 SQL 表达式赋值时,须重新查询取得实际字段值后再使用默认实例操作。`upsert()` 用于更新已有记录时,同样不能改变其分区字段。
230
+ - 缺少主键或分区字段时,默认实例操作返回 `false`。`save()` 没有待写字段时仍直接返回 `true`。
231
+ - 显式 `save(where)` 完整采用调用方提供的条件,不自动附加分区或业务条件。
232
+ - 未声明 `_$partition` 的模型保持仅按主键定位的原行为。静态查询、批量更新、删除等方法仍使用显式条件;租户、软删除和业务状态约束由应用负责。
233
+
234
+ `_$partition` 用于数据库原生分区,与 `index` 选项按表名后缀访问分表的机制不同。事务提交、回滚及连接生命周期保持原约定。
235
+
213
236
  query-pagination.md
214
237
  ---
215
238
 
@@ -1827,7 +1850,7 @@ index/variables/VER.md
1827
1850
 
1828
1851
  # Variable: VER
1829
1852
 
1830
- > `const` **VER**: `"9.27.0"` = `'9.27.0'`
1853
+ > `const` **VER**: `"9.27.1"` = `'9.27.1'`
1831
1854
 
1832
1855
  Defined in: [index.ts:9](https://github.com/maiyunnet/kebab/blob/master/index.ts#L9)
1833
1856
 
@@ -124368,7 +124391,7 @@ Defined in: [lib/sql.ts:76](https://github.com/maiyunnet/kebab/blob/master/lib/s
124368
124391
 
124369
124392
  > **append**(`sql`): `this`
124370
124393
 
124371
- Defined in: [lib/sql.ts:1126](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1126)
124394
+ Defined in: [lib/sql.ts:1127](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1127)
124372
124395
 
124373
124396
  在 sql 最后追加字符串
124374
124397
 
@@ -124388,7 +124411,7 @@ Defined in: [lib/sql.ts:1126](https://github.com/maiyunnet/kebab/blob/master/lib
124388
124411
 
124389
124412
  > **by**(`c`, `d?`): `this`
124390
124413
 
124391
- Defined in: [lib/sql.ts:813](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L813)
124414
+ Defined in: [lib/sql.ts:814](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L814)
124392
124415
 
124393
124416
  ORDER BY
124394
124417
 
@@ -124416,7 +124439,7 @@ ORDER BY
124416
124439
 
124417
124440
  > **copy**(`f?`, `opt?`): `Sql`
124418
124441
 
124419
- Defined in: [lib/sql.ts:932](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L932)
124442
+ Defined in: [lib/sql.ts:933](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L933)
124420
124443
 
124421
124444
  创建一个本对象的一个新的 sql 对象拷贝
124422
124445
 
@@ -124518,7 +124541,7 @@ Defined in: [lib/sql.ts:420](https://github.com/maiyunnet/kebab/blob/master/lib/
124518
124541
 
124519
124542
  > **field**(`str`, `pre?`, `suf?`): `string`
124520
124543
 
124521
- Defined in: [lib/sql.ts:1137](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1137)
124544
+ Defined in: [lib/sql.ts:1138](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1138)
124522
124545
 
124523
124546
  对字段进行包裹
124524
124547
 
@@ -124550,7 +124573,7 @@ MySQL 时为表前缀,PostgreSQL 时为 Schema 名,仅请在 field 表名时
124550
124573
 
124551
124574
  > **format**(`sql?`, `data?`): `string`
124552
124575
 
124553
- Defined in: [lib/sql.ts:1116](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1116)
124576
+ Defined in: [lib/sql.ts:1117](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1117)
124554
124577
 
124555
124578
  获取带 data 的 sql 语句
124556
124579
 
@@ -124614,7 +124637,7 @@ MySQL 时为表前缀,PostgreSQL 时为 Schema 名,仅在 join 非默认前
124614
124637
 
124615
124638
  > **getData**(): [`DbValue`](../../../index/type-aliases/DbValue.md)[]
124616
124639
 
124617
- Defined in: [lib/sql.ts:1100](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1100)
124640
+ Defined in: [lib/sql.ts:1101](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1101)
124618
124641
 
124619
124642
  获取全部 data
124620
124643
 
@@ -124628,7 +124651,7 @@ Defined in: [lib/sql.ts:1100](https://github.com/maiyunnet/kebab/blob/master/lib
124628
124651
 
124629
124652
  > **getPre**(): `string`
124630
124653
 
124631
- Defined in: [lib/sql.ts:1107](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1107)
124654
+ Defined in: [lib/sql.ts:1108](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1108)
124632
124655
 
124633
124656
  获取定义的 pre
124634
124657
 
@@ -124642,7 +124665,7 @@ Defined in: [lib/sql.ts:1107](https://github.com/maiyunnet/kebab/blob/master/lib
124642
124665
 
124643
124666
  > **getSql**(): `string`
124644
124667
 
124645
- Defined in: [lib/sql.ts:1080](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1080)
124668
+ Defined in: [lib/sql.ts:1081](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1081)
124646
124669
 
124647
124670
  获取 sql 语句
124648
124671
 
@@ -124656,7 +124679,7 @@ Defined in: [lib/sql.ts:1080](https://github.com/maiyunnet/kebab/blob/master/lib
124656
124679
 
124657
124680
  > **group**(`c`): `this`
124658
124681
 
124659
- Defined in: [lib/sql.ts:888](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L888)
124682
+ Defined in: [lib/sql.ts:889](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L889)
124660
124683
 
124661
124684
  GROUP BY
124662
124685
 
@@ -124897,7 +124920,7 @@ MySQL 时为表前缀,PostgreSQL 时为 Schema 名,仅在 join 非默认前
124897
124920
 
124898
124921
  > **limit**(`a`, `b?`): `this`
124899
124922
 
124900
- Defined in: [lib/sql.ts:908](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L908)
124923
+ Defined in: [lib/sql.ts:909](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L909)
124901
124924
 
124902
124925
  LIMIT(limit、offset, limit)
124903
124926
 
@@ -124925,7 +124948,7 @@ LIMIT(limit、offset, limit)
124925
124948
 
124926
124949
  > **lock**(): `this`
124927
124950
 
124928
- Defined in: [lib/sql.ts:923](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L923)
124951
+ Defined in: [lib/sql.ts:924](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L924)
124929
124952
 
124930
124953
  追加消极锁,通常不建议使用
124931
124954
 
@@ -124979,7 +125002,7 @@ MySQL 时为表前缀,PostgreSQL 时为 Schema 名,仅在 join 非默认前
124979
125002
 
124980
125003
  > **seek**(`c`, `values?`, `d?`): `this`
124981
125004
 
124982
- Defined in: [lib/sql.ts:841](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L841)
125005
+ Defined in: [lib/sql.ts:842](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L842)
124983
125006
 
124984
125007
  按非空、同向排序字段定位游标并设置排序;字段组合须唯一且有匹配索引
124985
125008
  使用行比较,让 PostgreSQL 可以从复合索引边界开始扫描
@@ -125221,10 +125244,11 @@ Defined in: [lib/sql.ts:154](https://github.com/maiyunnet/kebab/blob/master/lib/
125221
125244
 
125222
125245
  > **where**(`s`): `this`
125223
125246
 
125224
- Defined in: [lib/sql.ts:572](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L572)
125247
+ Defined in: [lib/sql.ts:573](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L573)
125225
125248
 
125226
125249
  筛选器
125227
- 标量相等:'city': 'bj', 'type': '2'
125250
+ 等值条件:'city': 'bj';字符串、数字、布尔值、bigint、Date 和 Buffer 均作为单个参数
125251
+ null 生成 IS NULL,数组生成 IN 条件
125228
125252
  运算符条件:['type', '>', '1']
125229
125253
  集合条件:['type', 'in', ['1', '2']] 或 'type': ['1', '2']
125230
125254
  逻辑分组:'$or': [{'city': 'bj'}, {'city': 'sh'}, [['age', '>', '10']]]
@@ -125363,7 +125387,7 @@ lib/sql/functions/aoMix.md
125363
125387
 
125364
125388
  > **aoMix**(`arr`): `Record`\<`string`, `string` \| `number` \| [`Json`](../../../index/type-aliases/Json.md)\>
125365
125389
 
125366
- Defined in: [lib/sql.ts:1486](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1486)
125390
+ Defined in: [lib/sql.ts:1487](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1487)
125367
125391
 
125368
125392
  将数组兑换为组合的对象(Array/Object mix)
125369
125393
 
@@ -125392,7 +125416,7 @@ lib/sql/functions/column.md
125392
125416
 
125393
125417
  > **column**(`field`): `object`
125394
125418
 
125395
- Defined in: [lib/sql.ts:1507](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1507)
125419
+ Defined in: [lib/sql.ts:1508](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1508)
125396
125420
 
125397
125421
  创建字段对象
125398
125422
 
@@ -125431,7 +125455,7 @@ lib/sql/functions/format.md
125431
125455
 
125432
125456
  > **format**(`sql`, `data`, `service?`): `string`
125433
125457
 
125434
- Defined in: [lib/sql.ts:1447](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1447)
125458
+ Defined in: [lib/sql.ts:1448](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1448)
125435
125459
 
125436
125460
  返回代入后的完整 SQL 字符串,这并不安全不能直接执行,只是用来调试打印 sql 语句
125437
125461
 
@@ -125472,7 +125496,7 @@ lib/sql/functions/get.md
125472
125496
 
125473
125497
  > **get**(`opt`): [`Sql`](../classes/Sql.md)
125474
125498
 
125475
- Defined in: [lib/sql.ts:1419](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1419)
125499
+ Defined in: [lib/sql.ts:1420](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1420)
125476
125500
 
125477
125501
  创建 sql 对象
125478
125502
 
@@ -125525,7 +125549,7 @@ lib/sql/functions/json.md
125525
125549
 
125526
125550
  > **json**\<`T`\>(`obj`): `T`
125527
125551
 
125528
- Defined in: [lib/sql.ts:1546](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1546)
125552
+ Defined in: [lib/sql.ts:1547](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1547)
125529
125553
 
125530
125554
  标记需要写入 JSON/jsonb 字段的值;实际序列化延迟到数据库边界
125531
125555
 
@@ -125562,7 +125586,7 @@ lib/sql/functions/value.md
125562
125586
 
125563
125587
  > **value**(`val`): `object`
125564
125588
 
125565
- Defined in: [lib/sql.ts:1526](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1526)
125589
+ Defined in: [lib/sql.ts:1527](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1527)
125566
125590
 
125567
125591
  创建字面量值对象,用于 where 条件中 v[0] 需要是值而非字段名的场景
125568
125592
  例:[value('hello'), 'IN', column('tags')]
@@ -136038,7 +136062,7 @@ Defined in: [sys/mod.ts:74](https://github.com/maiyunnet/kebab/blob/master/sys/m
136038
136062
 
136039
136063
  > **new default**(`opt`): `Mod`
136040
136064
 
136041
- Defined in: [sys/mod.ts:128](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L128)
136065
+ Defined in: [sys/mod.ts:135](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L135)
136042
136066
 
136043
136067
  构造函数
136044
136068
 
@@ -136112,7 +136136,7 @@ MySQL 表前缀或 PostgreSQL Schema 名,优先级:选项 > 类属性 > 配
136112
136136
 
136113
136137
  > `protected` **\_contain**: \{ `key`: `string`; `list`: `string`[]; \} \| `null` = `null`
136114
136138
 
136115
- Defined in: [sys/mod.ts:104](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L104)
136139
+ Defined in: [sys/mod.ts:111](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L111)
136116
136140
 
136117
136141
  必须追加的数据筛选 key 与 values,仅单表模式有效
136118
136142
 
@@ -136122,7 +136146,7 @@ Defined in: [sys/mod.ts:104](https://github.com/maiyunnet/kebab/blob/master/sys/
136122
136146
 
136123
136147
  > `protected` `optional` **\_ctr?**: [`Ctr`](../../ctr/classes/Ctr.md) = `undefined`
136124
136148
 
136125
- Defined in: [sys/mod.ts:119](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L119)
136149
+ Defined in: [sys/mod.ts:126](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L126)
136126
136150
 
136127
136151
  ctr 对象
136128
136152
 
@@ -136132,7 +136156,7 @@ ctr 对象
136132
136156
 
136133
136157
  > `protected` **\_data**: `Record`\<`string`, `any`\> = `{}`
136134
136158
 
136135
- Defined in: [sys/mod.ts:98](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L98)
136159
+ Defined in: [sys/mod.ts:105](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L105)
136136
136160
 
136137
136161
  模型获取的属性
136138
136162
 
@@ -136142,7 +136166,7 @@ Defined in: [sys/mod.ts:98](https://github.com/maiyunnet/kebab/blob/master/sys/m
136142
136166
 
136143
136167
  > `protected` **\_db**: [`Transaction`](../../../lib/db/tran/classes/Transaction.md) \| [`Pool`](../../../lib/db/pool/classes/Pool.md)
136144
136168
 
136145
- Defined in: [sys/mod.ts:113](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L113)
136169
+ Defined in: [sys/mod.ts:120](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L120)
136146
136170
 
136147
136171
  数据库连接对象
136148
136172
 
@@ -136152,7 +136176,7 @@ Defined in: [sys/mod.ts:113](https://github.com/maiyunnet/kebab/blob/master/sys/
136152
136176
 
136153
136177
  > `protected` **\_fieldPrefix**: `string` = `''`
136154
136178
 
136155
- Defined in: [sys/mod.ts:122](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L122)
136179
+ Defined in: [sys/mod.ts:129](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L129)
136156
136180
 
136157
136181
  主表筛选前缀,优先 alias,其次表名
136158
136182
 
@@ -136162,7 +136186,7 @@ Defined in: [sys/mod.ts:122](https://github.com/maiyunnet/kebab/blob/master/sys/
136162
136186
 
136163
136187
  > `protected` **\_index**: `string`[] \| `null` = `null`
136164
136188
 
136165
- Defined in: [sys/mod.ts:101](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L101)
136189
+ Defined in: [sys/mod.ts:108](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L108)
136166
136190
 
136167
136191
  当前选择的分表 _ 后缀,多个代表联查
136168
136192
 
@@ -136172,7 +136196,7 @@ Defined in: [sys/mod.ts:101](https://github.com/maiyunnet/kebab/blob/master/sys/
136172
136196
 
136173
136197
  > `protected` **\_jsonUpdates**: `Record`\<`string`, `boolean`\> = `{}`
136174
136198
 
136175
- Defined in: [sys/mod.ts:95](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L95)
136199
+ Defined in: [sys/mod.ts:102](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L102)
136176
136200
 
136177
136201
  要在数据库边界序列化的 JSON 字段
136178
136202
 
@@ -136182,7 +136206,7 @@ Defined in: [sys/mod.ts:95](https://github.com/maiyunnet/kebab/blob/master/sys/m
136182
136206
 
136183
136207
  > `protected` **\_sql**: [`Sql`](../../../lib/sql/classes/Sql.md)
136184
136208
 
136185
- Defined in: [sys/mod.ts:116](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L116)
136209
+ Defined in: [sys/mod.ts:123](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L123)
136186
136210
 
136187
136211
  Sql 对象
136188
136212
 
@@ -136192,7 +136216,7 @@ Sql 对象
136192
136216
 
136193
136217
  > `protected` **\_total**: `number`[] = `[]`
136194
136218
 
136195
- Defined in: [sys/mod.ts:110](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L110)
136219
+ Defined in: [sys/mod.ts:117](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L117)
136196
136220
 
136197
136221
  已算出的 total
136198
136222
 
@@ -136202,7 +136226,7 @@ Defined in: [sys/mod.ts:110](https://github.com/maiyunnet/kebab/blob/master/sys/
136202
136226
 
136203
136227
  > `protected` **\_updates**: `Record`\<`string`, `boolean`\> = `{}`
136204
136228
 
136205
- Defined in: [sys/mod.ts:92](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L92)
136229
+ Defined in: [sys/mod.ts:99](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L99)
136206
136230
 
136207
136231
  要 update 的内容
136208
136232
 
@@ -136212,7 +136236,7 @@ Defined in: [sys/mod.ts:92](https://github.com/maiyunnet/kebab/blob/master/sys/m
136212
136236
 
136213
136237
  > `protected` `static` **\_$index**: `string` \| `string`[] = `''`
136214
136238
 
136215
- Defined in: [sys/mod.ts:86](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L86)
136239
+ Defined in: [sys/mod.ts:93](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L93)
136216
136240
 
136217
136241
  自动 key 冲突目标:MySQL 为索引名;PGSQL 为唯一字段或字段数组,PG 留空使用 _$key,不支持部分或表达式索引
136218
136242
 
@@ -136222,17 +136246,29 @@ Defined in: [sys/mod.ts:86](https://github.com/maiyunnet/kebab/blob/master/sys/m
136222
136246
 
136223
136247
  > `protected` `static` **\_$key**: `string` = `''`
136224
136248
 
136225
- Defined in: [sys/mod.ts:83](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L83)
136249
+ Defined in: [sys/mod.ts:90](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L90)
136226
136250
 
136227
136251
  设置后将由 _keyGenerator 函数生成唯一字段
136228
136252
 
136229
136253
  ***
136230
136254
 
136255
+ ### \_$partition
136256
+
136257
+ > `protected` `static` **\_$partition**: `string`[] = `[]`
136258
+
136259
+ Defined in: [sys/mod.ts:87](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L87)
136260
+
136261
+ 表的分区字段名,如 ['time_push']
136262
+ save、remove、refresh 默认会把这些字段加入 WHERE 条件,与主键一起查找记录。
136263
+ 读取记录后不要修改主键或分区字段;留空时只使用主键。
136264
+
136265
+ ***
136266
+
136231
136267
  ### \_$pre?
136232
136268
 
136233
136269
  > `protected` `static` `optional` **\_$pre?**: `string`
136234
136270
 
136235
- Defined in: [sys/mod.ts:89](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L89)
136271
+ Defined in: [sys/mod.ts:96](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L96)
136236
136272
 
136237
136273
  前缀,MySQL 时为表前缀(如 prefix_),PostgreSQL 时为 Schema 名。顺序:选项前缀 -> 本前缀 -> 配置文件前缀
136238
136274
 
@@ -136262,7 +136298,7 @@ Defined in: [sys/mod.ts:77](https://github.com/maiyunnet/kebab/blob/master/sys/m
136262
136298
 
136263
136299
  > `protected` **\_keyGenerator**(): `string`
136264
136300
 
136265
- Defined in: [sys/mod.ts:2048](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2048)
136301
+ Defined in: [sys/mod.ts:2074](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2074)
136266
136302
 
136267
136303
  当 _key 不为空时,则依据继承此方法的方法自动生成填充 key
136268
136304
 
@@ -136286,7 +136322,7 @@ Defined in: [sys/mod.ts:2048](https://github.com/maiyunnet/kebab/blob/master/sys
136286
136322
 
136287
136323
  > **all**(): `Promise`\<`false` \| [`Rows`](Rows.md)\<`Mod`\>\>
136288
136324
 
136289
- Defined in: [sys/mod.ts:1271](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1271)
136325
+ Defined in: [sys/mod.ts:1297](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1297)
136290
136326
 
136291
136327
  ##### Returns
136292
136328
 
@@ -136296,7 +136332,7 @@ Defined in: [sys/mod.ts:1271](https://github.com/maiyunnet/kebab/blob/master/sys
136296
136332
 
136297
136333
  > **all**(`key`): `Promise`\<`false` \| `Record`\<`string`, `Mod`\>\>
136298
136334
 
136299
- Defined in: [sys/mod.ts:1272](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1272)
136335
+ Defined in: [sys/mod.ts:1298](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1298)
136300
136336
 
136301
136337
  ##### Parameters
136302
136338
 
@@ -136324,7 +136360,7 @@ Defined in: [sys/mod.ts:1272](https://github.com/maiyunnet/kebab/blob/master/sys
136324
136360
 
136325
136361
  > **allArray**(): `Promise`\<`false` \| `Record`\<`string`, `any`\>[]\>
136326
136362
 
136327
- Defined in: [sys/mod.ts:1450](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1450)
136363
+ Defined in: [sys/mod.ts:1476](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1476)
136328
136364
 
136329
136365
  ##### Returns
136330
136366
 
@@ -136334,7 +136370,7 @@ Defined in: [sys/mod.ts:1450](https://github.com/maiyunnet/kebab/blob/master/sys
136334
136370
 
136335
136371
  > **allArray**(`key`): `Promise`\<`false` \| `Record`\<`string`, `Record`\<`string`, `any`\>\>\>
136336
136372
 
136337
- Defined in: [sys/mod.ts:1451](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1451)
136373
+ Defined in: [sys/mod.ts:1477](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1477)
136338
136374
 
136339
136375
  ##### Parameters
136340
136376
 
@@ -136352,7 +136388,7 @@ Defined in: [sys/mod.ts:1451](https://github.com/maiyunnet/kebab/blob/master/sys
136352
136388
 
136353
136389
  > **allCursor**\<`T`\>(`count`, `opt`): `Promise`\<`false` \| [`ICursorPage`](../interfaces/ICursorPage.md)\<`T`\>\>
136354
136390
 
136355
- Defined in: [sys/mod.ts:1699](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1699)
136391
+ Defined in: [sys/mod.ts:1725](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1725)
136356
136392
 
136357
136393
  读取一批游标数据,多取一条判断后续记录,不使用 OFFSET,不修改原查询
136358
136394
  排序字段必须全部非空、同向,且组合唯一;SELECT 中须包含对应字段(同名或指定 keys)
@@ -136417,7 +136453,7 @@ SELECT 结果中对应的字段名,默认去掉 by 的表别名
136417
136453
 
136418
136454
  > **append**(`sql`): `this`
136419
136455
 
136420
- Defined in: [sys/mod.ts:1957](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1957)
136456
+ Defined in: [sys/mod.ts:1983](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1983)
136421
136457
 
136422
136458
  在 sql 最后追加字符串
136423
136459
 
@@ -136437,7 +136473,7 @@ Defined in: [sys/mod.ts:1957](https://github.com/maiyunnet/kebab/blob/master/sys
136437
136473
 
136438
136474
  > **by**(`c`, `d?`): `this`
136439
136475
 
136440
- Defined in: [sys/mod.ts:1913](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1913)
136476
+ Defined in: [sys/mod.ts:1939](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1939)
136441
136477
 
136442
136478
  ORDER BY
136443
136479
 
@@ -136465,7 +136501,7 @@ ORDER BY
136465
136501
 
136466
136502
  > **contain**(`contain`): `this`
136467
136503
 
136468
- Defined in: [sys/mod.ts:1966](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1966)
136504
+ Defined in: [sys/mod.ts:1992](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1992)
136469
136505
 
136470
136506
  设置闭包含数据
136471
136507
 
@@ -136493,7 +136529,7 @@ Defined in: [sys/mod.ts:1966](https://github.com/maiyunnet/kebab/blob/master/sys
136493
136529
 
136494
136530
  > **count**(): `Promise`\<`number`\>
136495
136531
 
136496
- Defined in: [sys/mod.ts:1749](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1749)
136532
+ Defined in: [sys/mod.ts:1775](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1775)
136497
136533
 
136498
136534
  根据当前条件,筛选出当前条目该有的数据条数
136499
136535
 
@@ -136507,7 +136543,7 @@ Defined in: [sys/mod.ts:1749](https://github.com/maiyunnet/kebab/blob/master/sys
136507
136543
 
136508
136544
  > **countSql**(): `string`
136509
136545
 
136510
- Defined in: [sys/mod.ts:1770](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1770)
136546
+ Defined in: [sys/mod.ts:1796](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1796)
136511
136547
 
136512
136548
  获取当前条件下的 count 的 SQL 语句
136513
136549
 
@@ -136521,7 +136557,7 @@ Defined in: [sys/mod.ts:1770](https://github.com/maiyunnet/kebab/blob/master/sys
136521
136557
 
136522
136558
  > **create**(): `Promise`\<`boolean` \| `null`\>
136523
136559
 
136524
- Defined in: [sys/mod.ts:901](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L901)
136560
+ Defined in: [sys/mod.ts:928](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L928)
136525
136561
 
136526
136562
  创建数据,自动 key 最多尝试 3 次;PGSQL 仅忽略指定字段的唯一冲突
136527
136563
 
@@ -136537,7 +136573,7 @@ true-成功,false-错误或重试耗尽,null-其他唯一冲突;PGSQL 的 SQL
136537
136573
 
136538
136574
  > **crossJoin**(`f`, `s`, `index?`, `pre?`): `this`
136539
136575
 
136540
- Defined in: [sys/mod.ts:1845](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1845)
136576
+ Defined in: [sys/mod.ts:1871](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1871)
136541
136577
 
136542
136578
  cross join 方法
136543
136579
 
@@ -136587,7 +136623,7 @@ ON 信息
136587
136623
 
136588
136624
  > **explain**(`all?`): `Promise`\<`string` \| `false`\>
136589
136625
 
136590
- Defined in: [sys/mod.ts:1576](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1576)
136626
+ Defined in: [sys/mod.ts:1602](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1602)
136591
136627
 
136592
136628
  ##### Parameters
136593
136629
 
@@ -136603,7 +136639,7 @@ Defined in: [sys/mod.ts:1576](https://github.com/maiyunnet/kebab/blob/master/sys
136603
136639
 
136604
136640
  > **explain**(`all`): `Promise`\<`false` \| `Record`\<`string`, `any`\>\>
136605
136641
 
136606
- Defined in: [sys/mod.ts:1577](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1577)
136642
+ Defined in: [sys/mod.ts:1603](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1603)
136607
136643
 
136608
136644
  ##### Parameters
136609
136645
 
@@ -136621,7 +136657,7 @@ Defined in: [sys/mod.ts:1577](https://github.com/maiyunnet/kebab/blob/master/sys
136621
136657
 
136622
136658
  > **filter**(`s`): `this`
136623
136659
 
136624
- Defined in: [sys/mod.ts:1891](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1891)
136660
+ Defined in: [sys/mod.ts:1917](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1917)
136625
136661
 
136626
136662
  筛选器
136627
136663
 
@@ -136659,7 +136695,7 @@ Defined in: [sys/mod.ts:1891](https://github.com/maiyunnet/kebab/blob/master/sys
136659
136695
 
136660
136696
  > **first**(`lock`, `array`): `Promise`\<`false` \| `Record`\<`string`, `any`\> \| `null`\>
136661
136697
 
136662
- Defined in: [sys/mod.ts:1160](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1160)
136698
+ Defined in: [sys/mod.ts:1186](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1186)
136663
136699
 
136664
136700
  ##### Parameters
136665
136701
 
@@ -136679,7 +136715,7 @@ Defined in: [sys/mod.ts:1160](https://github.com/maiyunnet/kebab/blob/master/sys
136679
136715
 
136680
136716
  > **first**(`lock?`, `array?`): `Promise`\<`false` \| `Mod` & `Record`\<`string`, `any`\> \| `null`\>
136681
136717
 
136682
- Defined in: [sys/mod.ts:1164](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1164)
136718
+ Defined in: [sys/mod.ts:1190](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1190)
136683
136719
 
136684
136720
  ##### Parameters
136685
136721
 
@@ -136701,7 +136737,7 @@ Defined in: [sys/mod.ts:1164](https://github.com/maiyunnet/kebab/blob/master/sys
136701
136737
 
136702
136738
  > **firstArray**(`lock?`): `Promise`\<`false` \| `Record`\<`string`, `any`\> \| `null`\>
136703
136739
 
136704
- Defined in: [sys/mod.ts:1204](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1204)
136740
+ Defined in: [sys/mod.ts:1230](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1230)
136705
136741
 
136706
136742
  获取数据库第一个原生对象
136707
136743
 
@@ -136723,7 +136759,7 @@ Defined in: [sys/mod.ts:1204](https://github.com/maiyunnet/kebab/blob/master/sys
136723
136759
 
136724
136760
  > **format**(`sql?`, `data?`): `string`
136725
136761
 
136726
- Defined in: [sys/mod.ts:1993](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1993)
136762
+ Defined in: [sys/mod.ts:2019](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2019)
136727
136763
 
136728
136764
  获取带 data 的 sql 语句
136729
136765
 
@@ -136751,7 +136787,7 @@ sql 语句
136751
136787
 
136752
136788
  > **fullJoin**(`f`, `s`, `index?`, `pre?`): `this`
136753
136789
 
136754
- Defined in: [sys/mod.ts:1833](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1833)
136790
+ Defined in: [sys/mod.ts:1859](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1859)
136755
136791
 
136756
136792
  full join 方法
136757
136793
 
@@ -136791,7 +136827,7 @@ ON 信息
136791
136827
 
136792
136828
  > **get**(`n`): `any`
136793
136829
 
136794
- Defined in: [sys/mod.ts:881](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L881)
136830
+ Defined in: [sys/mod.ts:908](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L908)
136795
136831
 
136796
136832
  获取一个字段值
136797
136833
 
@@ -136813,7 +136849,7 @@ Defined in: [sys/mod.ts:881](https://github.com/maiyunnet/kebab/blob/master/sys/
136813
136849
 
136814
136850
  > **getData**(): `any`[]
136815
136851
 
136816
- Defined in: [sys/mod.ts:1984](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1984)
136852
+ Defined in: [sys/mod.ts:2010](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2010)
136817
136853
 
136818
136854
  获取全部 data
136819
136855
 
@@ -136827,7 +136863,7 @@ Defined in: [sys/mod.ts:1984](https://github.com/maiyunnet/kebab/blob/master/sys
136827
136863
 
136828
136864
  > **getSql**(): `string`
136829
136865
 
136830
- Defined in: [sys/mod.ts:1977](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1977)
136866
+ Defined in: [sys/mod.ts:2003](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2003)
136831
136867
 
136832
136868
  获取 sql 语句
136833
136869
 
@@ -136841,7 +136877,7 @@ Defined in: [sys/mod.ts:1977](https://github.com/maiyunnet/kebab/blob/master/sys
136841
136877
 
136842
136878
  > **group**(`c`): `this`
136843
136879
 
136844
- Defined in: [sys/mod.ts:1922](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1922)
136880
+ Defined in: [sys/mod.ts:1948](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1948)
136845
136881
 
136846
136882
  GROUP BY
136847
136883
 
@@ -136863,7 +136899,7 @@ GROUP BY
136863
136899
 
136864
136900
  > **having**(`s`): `this`
136865
136901
 
136866
- Defined in: [sys/mod.ts:1882](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1882)
136902
+ Defined in: [sys/mod.ts:1908](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1908)
136867
136903
 
136868
136904
  筛选器
136869
136905
 
@@ -136885,7 +136921,7 @@ Defined in: [sys/mod.ts:1882](https://github.com/maiyunnet/kebab/blob/master/sys
136885
136921
 
136886
136922
  > **hint**(`h`): `this`
136887
136923
 
136888
- Defined in: [sys/mod.ts:1873](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1873)
136924
+ Defined in: [sys/mod.ts:1899](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1899)
136889
136925
 
136890
136926
  设置 MySQL 优化器 Hint
136891
136927
  内容会以 Optimizer Hint 注释语法注入到 SELECT 关键字后
@@ -136930,7 +136966,7 @@ Hint 内容
136930
136966
 
136931
136967
  > **innerJoin**(`f`, `s`, `index?`, `pre?`): `this`
136932
136968
 
136933
- Defined in: [sys/mod.ts:1821](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1821)
136969
+ Defined in: [sys/mod.ts:1847](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1847)
136934
136970
 
136935
136971
  inner join 方法
136936
136972
 
@@ -136970,7 +137006,7 @@ ON 信息
136970
137006
 
136971
137007
  > **join**(`f`, `s?`, `type?`, `index?`, `pre?`): `this`
136972
137008
 
136973
- Defined in: [sys/mod.ts:1785](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1785)
137009
+ Defined in: [sys/mod.ts:1811](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1811)
136974
137010
 
136975
137011
  #### Parameters
136976
137012
 
@@ -137014,7 +137050,7 @@ ON 信息
137014
137050
 
137015
137051
  > **langText**(`col`, `lang`): `string`
137016
137052
 
137017
- Defined in: [sys/mod.ts:2028](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2028)
137053
+ Defined in: [sys/mod.ts:2054](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2054)
137018
137054
 
137019
137055
  获取字段的可用语种文本
137020
137056
 
@@ -137042,7 +137078,7 @@ Defined in: [sys/mod.ts:2028](https://github.com/maiyunnet/kebab/blob/master/sys
137042
137078
 
137043
137079
  > **leftJoin**(`f`, `s`, `index?`, `pre?`): `this`
137044
137080
 
137045
- Defined in: [sys/mod.ts:1797](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1797)
137081
+ Defined in: [sys/mod.ts:1823](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1823)
137046
137082
 
137047
137083
  left join 方法
137048
137084
 
@@ -137082,7 +137118,7 @@ ON 信息
137082
137118
 
137083
137119
  > **limit**(`a`, `b?`): `this`
137084
137120
 
137085
- Defined in: [sys/mod.ts:1935](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1935)
137121
+ Defined in: [sys/mod.ts:1961](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1961)
137086
137122
 
137087
137123
  LIMIT
137088
137124
 
@@ -137110,7 +137146,7 @@ LIMIT
137110
137146
 
137111
137147
  > **page**(`count`, `page?`): `this`
137112
137148
 
137113
- Defined in: [sys/mod.ts:1946](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1946)
137149
+ Defined in: [sys/mod.ts:1972](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1972)
137114
137150
 
137115
137151
  分页
137116
137152
 
@@ -137138,7 +137174,7 @@ Defined in: [sys/mod.ts:1946](https://github.com/maiyunnet/kebab/blob/master/sys
137138
137174
 
137139
137175
  > **refresh**(`lock?`): `Promise`\<`boolean` \| `null`\>
137140
137176
 
137141
- Defined in: [sys/mod.ts:1069](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1069)
137177
+ Defined in: [sys/mod.ts:1097](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1097)
137142
137178
 
137143
137179
  刷新当前模型获取最新数据
137144
137180
 
@@ -137154,27 +137190,31 @@ Defined in: [sys/mod.ts:1069](https://github.com/maiyunnet/kebab/blob/master/sys
137154
137190
 
137155
137191
  `Promise`\<`boolean` \| `null`\>
137156
137192
 
137193
+ true 成功,null 记录不存在,false 缺少定位字段或查询失败
137194
+
137157
137195
  ***
137158
137196
 
137159
137197
  ### remove()
137160
137198
 
137161
137199
  > **remove**(): `Promise`\<`boolean`\>
137162
137200
 
137163
- Defined in: [sys/mod.ts:1138](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1138)
137201
+ Defined in: [sys/mod.ts:1165](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1165)
137164
137202
 
137165
- 移除本条目
137203
+ 按主键和分区字段删除当前记录
137166
137204
 
137167
137205
  #### Returns
137168
137206
 
137169
137207
  `Promise`\<`boolean`\>
137170
137208
 
137209
+ 是否成功,缺少定位字段、记录不存在或删除失败返回 false
137210
+
137171
137211
  ***
137172
137212
 
137173
137213
  ### rightJoin()
137174
137214
 
137175
137215
  > **rightJoin**(`f`, `s`, `index?`, `pre?`): `this`
137176
137216
 
137177
- Defined in: [sys/mod.ts:1809](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1809)
137217
+ Defined in: [sys/mod.ts:1835](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1835)
137178
137218
 
137179
137219
  right join 方法
137180
137220
 
@@ -137214,7 +137254,7 @@ ON 信息
137214
137254
 
137215
137255
  > **save**(`where?`): `Promise`\<`boolean`\>
137216
137256
 
137217
- Defined in: [sys/mod.ts:1102](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1102)
137257
+ Defined in: [sys/mod.ts:1129](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1129)
137218
137258
 
137219
137259
  更新 set 的数据到数据库,有未保存数据时才保存
137220
137260
 
@@ -137224,13 +137264,13 @@ Defined in: [sys/mod.ts:1102](https://github.com/maiyunnet/kebab/blob/master/sys
137224
137264
 
137225
137265
  `any`
137226
137266
 
137227
- 非空筛选条件,省略时必须有主键
137267
+ 显式非空筛选条件;省略时使用主键和分区字段值
137228
137268
 
137229
137269
  #### Returns
137230
137270
 
137231
137271
  `Promise`\<`boolean`\>
137232
137272
 
137233
- 是否成功,失败保留待写数据
137273
+ 是否成功,缺少默认定位字段或写入失败返回 false 并保留待写数据
137234
137274
 
137235
137275
  ***
137236
137276
 
@@ -137254,7 +137294,7 @@ Defined in: [sys/mod.ts:1102](https://github.com/maiyunnet/kebab/blob/master/sys
137254
137294
 
137255
137295
  > **set**\<`T`, `TK`\>(`n`): `void`
137256
137296
 
137257
- Defined in: [sys/mod.ts:846](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L846)
137297
+ Defined in: [sys/mod.ts:873](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L873)
137258
137298
 
137259
137299
  ##### Type Parameters
137260
137300
 
@@ -137280,7 +137320,7 @@ Defined in: [sys/mod.ts:846](https://github.com/maiyunnet/kebab/blob/master/sys/
137280
137320
 
137281
137321
  > **set**\<`T`, `TK`\>(`n`, `v`): `void`
137282
137322
 
137283
- Defined in: [sys/mod.ts:847](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L847)
137323
+ Defined in: [sys/mod.ts:874](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L874)
137284
137324
 
137285
137325
  ##### Type Parameters
137286
137326
 
@@ -137312,7 +137352,7 @@ Defined in: [sys/mod.ts:847](https://github.com/maiyunnet/kebab/blob/master/sys/
137312
137352
 
137313
137353
  > **toArray**\<`TC`\>(): [`TOnlyProperties`](../type-aliases/TOnlyProperties.md)\<`InstanceType`\<`TC`\>\> & `Record`\<`string`, `any`\>
137314
137354
 
137315
- Defined in: [sys/mod.ts:2000](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2000)
137355
+ Defined in: [sys/mod.ts:2026](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2026)
137316
137356
 
137317
137357
  获取值对象,获取的是新创建的数组
137318
137358
 
@@ -137332,7 +137372,7 @@ Defined in: [sys/mod.ts:2000](https://github.com/maiyunnet/kebab/blob/master/sys
137332
137372
 
137333
137373
  > **total**(`f?`): `Promise`\<`number`\>
137334
137374
 
137335
- Defined in: [sys/mod.ts:1634](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1634)
137375
+ Defined in: [sys/mod.ts:1660](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1660)
137336
137376
 
137337
137377
  获取总条数,自动抛弃 LIMIT,仅用于获取数据的情况(select)
137338
137378
 
@@ -137352,7 +137392,7 @@ Defined in: [sys/mod.ts:1634](https://github.com/maiyunnet/kebab/blob/master/sys
137352
137392
 
137353
137393
  > **totalEstimate**(): `Promise`\<`number` \| `false`\>
137354
137394
 
137355
- Defined in: [sys/mod.ts:1660](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1660)
137395
+ Defined in: [sys/mod.ts:1686](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1686)
137356
137396
 
137357
137397
  从 PostgreSQL 执行计划估算查询总行数,移除外层排序和分页,不执行数据扫描
137358
137398
  请在应用游标条件前调用;非 PostgreSQL、框架分表联查或查询失败返回 false,绝不回退到 COUNT
@@ -137369,7 +137409,7 @@ Defined in: [sys/mod.ts:1660](https://github.com/maiyunnet/kebab/blob/master/sys
137369
137409
 
137370
137410
  > **union**(`f`, `type?`): `this`
137371
137411
 
137372
- Defined in: [sys/mod.ts:1215](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1215)
137412
+ Defined in: [sys/mod.ts:1241](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1241)
137373
137413
 
137374
137414
  联合查询表数据
137375
137415
 
@@ -137397,7 +137437,7 @@ Defined in: [sys/mod.ts:1215](https://github.com/maiyunnet/kebab/blob/master/sys
137397
137437
 
137398
137438
  > **unionAll**(`f`): `this`
137399
137439
 
137400
- Defined in: [sys/mod.ts:1245](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1245)
137440
+ Defined in: [sys/mod.ts:1271](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1271)
137401
137441
 
137402
137442
  所有联合查询表数据
137403
137443
 
@@ -137419,7 +137459,7 @@ Defined in: [sys/mod.ts:1245](https://github.com/maiyunnet/kebab/blob/master/sys
137419
137459
 
137420
137460
  > **unsaved**(): `boolean`
137421
137461
 
137422
- Defined in: [sys/mod.ts:2019](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2019)
137462
+ Defined in: [sys/mod.ts:2045](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2045)
137423
137463
 
137424
137464
  当前是否设置了未保存 --=
137425
137465
 
@@ -137433,7 +137473,7 @@ Defined in: [sys/mod.ts:2019](https://github.com/maiyunnet/kebab/blob/master/sys
137433
137473
 
137434
137474
  > **updates**(): `Record`\<`string`, `any`\>
137435
137475
 
137436
- Defined in: [sys/mod.ts:2008](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2008)
137476
+ Defined in: [sys/mod.ts:2034](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2034)
137437
137477
 
137438
137478
  获取当前设置要提交的数据
137439
137479
 
@@ -137447,7 +137487,7 @@ Defined in: [sys/mod.ts:2008](https://github.com/maiyunnet/kebab/blob/master/sys
137447
137487
 
137448
137488
  > **upsert**(`conflict`): `Promise`\<`boolean`\>
137449
137489
 
137450
- Defined in: [sys/mod.ts:995](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L995)
137490
+ Defined in: [sys/mod.ts:1022](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1022)
137451
137491
 
137452
137492
  插入数据,如果业务唯一键已存在则更新,保留已有主键和自动 key
137453
137493
  PGSQL 为原子 UPSERT,自动 key 只生成一次,SQL 错误需回滚事务
@@ -137473,7 +137513,7 @@ MySQL 分步执行;自动 key 有多个唯一索引时须配置 _$index,整
137473
137513
 
137474
137514
  > **where**(`s`): `this`
137475
137515
 
137476
- Defined in: [sys/mod.ts:1902](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1902)
137516
+ Defined in: [sys/mod.ts:1928](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1928)
137477
137517
 
137478
137518
  是 filter 的别名
137479
137519
 
@@ -137495,7 +137535,7 @@ Defined in: [sys/mod.ts:1902](https://github.com/maiyunnet/kebab/blob/master/sys
137495
137535
 
137496
137536
  > `static` **column**(`field`): `object`
137497
137537
 
137498
- Defined in: [sys/mod.ts:193](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L193)
137538
+ Defined in: [sys/mod.ts:200](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L200)
137499
137539
 
137500
137540
  创建字段对象
137501
137541
 
@@ -137527,7 +137567,7 @@ Defined in: [sys/mod.ts:193](https://github.com/maiyunnet/kebab/blob/master/sys/
137527
137567
 
137528
137568
  > `static` **find**\<`T`\>(`db`, `val`, `opt?`): `Promise`\<`false` \| `T` & `Record`\<`string`, `any`\> \| `null`\>
137529
137569
 
137530
- Defined in: [sys/mod.ts:642](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L642)
137570
+ Defined in: [sys/mod.ts:649](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L649)
137531
137571
 
137532
137572
  根据主键(或 key 字段)获取对象
137533
137573
 
@@ -137591,7 +137631,7 @@ Defined in: [sys/mod.ts:642](https://github.com/maiyunnet/kebab/blob/master/sys/
137591
137631
 
137592
137632
  > `static` **getCreate**\<`T`\>(`db`, `opt?`): `T`
137593
137633
 
137594
- Defined in: [sys/mod.ts:624](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L624)
137634
+ Defined in: [sys/mod.ts:631](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L631)
137595
137635
 
137596
137636
  获取创建对象,通常用于新建数据库条目
137597
137637
 
@@ -137635,7 +137675,7 @@ Defined in: [sys/mod.ts:624](https://github.com/maiyunnet/kebab/blob/master/sys/
137635
137675
 
137636
137676
  > `static` **insert**(`db`, `cs`, `vs?`, `opt?`): `Promise`\<`boolean` \| `null`\>
137637
137677
 
137638
- Defined in: [sys/mod.ts:222](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L222)
137678
+ Defined in: [sys/mod.ts:229](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L229)
137639
137679
 
137640
137680
  添加一个序列(允许超过 65536 的占位符会被拆分多次执行)
137641
137681
 
@@ -137689,7 +137729,7 @@ Defined in: [sys/mod.ts:222](https://github.com/maiyunnet/kebab/blob/master/sys/
137689
137729
 
137690
137730
  > `static` **insertSql**(`db`, `cs`, `vs?`, `opt?`): `string`
137691
137731
 
137692
- Defined in: [sys/mod.ts:282](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L282)
137732
+ Defined in: [sys/mod.ts:289](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L289)
137693
137733
 
137694
137734
  获取添加一个序列的模拟 SQL
137695
137735
 
@@ -137743,7 +137783,7 @@ Defined in: [sys/mod.ts:282](https://github.com/maiyunnet/kebab/blob/master/sys/
137743
137783
 
137744
137784
  > `static` **json**\<`T`\>(`obj`): `T`
137745
137785
 
137746
- Defined in: [sys/mod.ts:211](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L211)
137786
+ Defined in: [sys/mod.ts:218](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L218)
137747
137787
 
137748
137788
  标记 JSON 字段;模型内保持原始对象,写入数据库时再序列化
137749
137789
 
@@ -137791,7 +137831,7 @@ Defined in: [sys/mod.ts:211](https://github.com/maiyunnet/kebab/blob/master/sys/
137791
137831
 
137792
137832
  > `static` **one**(`db`, `s`, `opt`): `Promise`\<`false` \| `Record`\<`string`, `any`\> \| `null`\>
137793
137833
 
137794
- Defined in: [sys/mod.ts:671](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L671)
137834
+ Defined in: [sys/mod.ts:678](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L678)
137795
137835
 
137796
137836
  ##### Parameters
137797
137837
 
@@ -137845,7 +137885,7 @@ Defined in: [sys/mod.ts:671](https://github.com/maiyunnet/kebab/blob/master/sys/
137845
137885
 
137846
137886
  > `static` **one**\<`T`\>(`db`, `s`, `opt?`): `Promise`\<`false` \| `T` & `Record`\<`string`, `any`\> \| `null`\>
137847
137887
 
137848
- Defined in: [sys/mod.ts:685](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L685)
137888
+ Defined in: [sys/mod.ts:692](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L692)
137849
137889
 
137850
137890
  ##### Type Parameters
137851
137891
 
@@ -137907,7 +137947,7 @@ Defined in: [sys/mod.ts:685](https://github.com/maiyunnet/kebab/blob/master/sys/
137907
137947
 
137908
137948
  > `static` **oneArray**(`db`, `s`, `opt?`): `Promise`\<`false` \| `Record`\<`string`, `any`\> \| `null`\>
137909
137949
 
137910
- Defined in: [sys/mod.ts:766](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L766)
137950
+ Defined in: [sys/mod.ts:773](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L773)
137911
137951
 
137912
137952
  通过 where 条件筛选单条数据返回原生对象
137913
137953
 
@@ -137963,7 +138003,7 @@ Defined in: [sys/mod.ts:766](https://github.com/maiyunnet/kebab/blob/master/sys/
137963
138003
 
137964
138004
  > `static` **primarys**(`db`, `where?`, `opt?`): `Promise`\<`false` \| `any`[]\>
137965
138005
 
137966
- Defined in: [sys/mod.ts:788](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L788)
138006
+ Defined in: [sys/mod.ts:795](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L795)
137967
138007
 
137968
138008
  根据 where 条件获取主键值列表
137969
138009
 
@@ -138007,7 +138047,7 @@ where 条件
138007
138047
 
138008
138048
  > `static` **removeByWhere**(`db`, `where`, `opt?`): `Promise`\<`number` \| `false` \| `null`\>
138009
138049
 
138010
- Defined in: [sys/mod.ts:308](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L308)
138050
+ Defined in: [sys/mod.ts:315](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L315)
138011
138051
 
138012
138052
  根据条件移除条目
138013
138053
 
@@ -138059,7 +138099,7 @@ Defined in: [sys/mod.ts:308](https://github.com/maiyunnet/kebab/blob/master/sys/
138059
138099
 
138060
138100
  > `static` **removeByWhereSql**(`db`, `where`, `opt?`): [`Sql`](../../../lib/sql/classes/Sql.md)
138061
138101
 
138062
- Defined in: [sys/mod.ts:352](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L352)
138102
+ Defined in: [sys/mod.ts:359](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L359)
138063
138103
 
138064
138104
  根据条件移除条目(仅获取 SQL 对象)
138065
138105
 
@@ -138111,7 +138151,7 @@ Defined in: [sys/mod.ts:352](https://github.com/maiyunnet/kebab/blob/master/sys/
138111
138151
 
138112
138152
  > `static` **select**\<`T`\>(`db`, `c`, `opt?`): `T` & `Record`\<`string`, `any`\>
138113
138153
 
138114
- Defined in: [sys/mod.ts:561](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L561)
138154
+ Defined in: [sys/mod.ts:568](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L568)
138115
138155
 
138116
138156
  select 自定字段
138117
138157
 
@@ -138181,7 +138221,7 @@ select 自定字段
138181
138221
 
138182
138222
  > `static` **toArrayByRecord**\<`T`\>(`obj`): `Record`\<`string`, `Record`\<`string`, `any`\>\>
138183
138223
 
138184
- Defined in: [sys/mod.ts:815](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L815)
138224
+ Defined in: [sys/mod.ts:822](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L822)
138185
138225
 
138186
138226
  将 key val 组成的数据列表转换为原生对象模式,获取的是新创建的数组
138187
138227
 
@@ -138209,7 +138249,7 @@ Defined in: [sys/mod.ts:815](https://github.com/maiyunnet/kebab/blob/master/sys/
138209
138249
 
138210
138250
  > `static` **updateByWhere**(`db`, `data`, `where`, `opt?`): `Promise`\<`number` \| `false` \| `null`\>
138211
138251
 
138212
- Defined in: [sys/mod.ts:385](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L385)
138252
+ Defined in: [sys/mod.ts:392](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L392)
138213
138253
 
138214
138254
  根据条件更新数据
138215
138255
 
@@ -138267,7 +138307,7 @@ Defined in: [sys/mod.ts:385](https://github.com/maiyunnet/kebab/blob/master/sys/
138267
138307
 
138268
138308
  > `static` **updateByWhereSql**(`db`, `data`, `where`, `opt?`): [`Sql`](../../../lib/sql/classes/Sql.md)
138269
138309
 
138270
- Defined in: [sys/mod.ts:431](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L431)
138310
+ Defined in: [sys/mod.ts:438](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L438)
138271
138311
 
138272
138312
  根据条件更新数据(仅获取 SQL 对象)
138273
138313
 
@@ -138325,7 +138365,7 @@ Defined in: [sys/mod.ts:431](https://github.com/maiyunnet/kebab/blob/master/sys/
138325
138365
 
138326
138366
  > `static` **updateList**(`db`, `data`, `key`, `opt?`): `Promise`\<`boolean` \| `null`\>
138327
138367
 
138328
- Defined in: [sys/mod.ts:469](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L469)
138368
+ Defined in: [sys/mod.ts:476](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L476)
138329
138369
 
138330
138370
  批量更新数据
138331
138371
 
@@ -138383,7 +138423,7 @@ Defined in: [sys/mod.ts:469](https://github.com/maiyunnet/kebab/blob/master/sys/
138383
138423
 
138384
138424
  > `static` **value**(`val`): `object`
138385
138425
 
138386
- Defined in: [sys/mod.ts:202](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L202)
138426
+ Defined in: [sys/mod.ts:209](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L209)
138387
138427
 
138388
138428
  创建字面量值对象,用于 where 条件中 v[0] 需要是值而非字段名的场景
138389
138429
 
@@ -138415,7 +138455,7 @@ Defined in: [sys/mod.ts:202](https://github.com/maiyunnet/kebab/blob/master/sys/
138415
138455
 
138416
138456
  > `static` **where**\<`T`\>(`db`, `s?`, `opt?`): `T` & `Record`\<`string`, `any`\>
138417
138457
 
138418
- Defined in: [sys/mod.ts:593](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L593)
138458
+ Defined in: [sys/mod.ts:600](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L600)
138419
138459
 
138420
138460
  通过 where 条件获取模型
138421
138461
 
@@ -138738,7 +138778,7 @@ sys/mod/interfaces/IModUnionItem.md
138738
138778
 
138739
138779
  # Interface: IModUnionItem
138740
138780
 
138741
- Defined in: [sys/mod.ts:2062](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2062)
138781
+ Defined in: [sys/mod.ts:2088](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2088)
138742
138782
 
138743
138783
  ## Properties
138744
138784
 
@@ -138746,7 +138786,7 @@ Defined in: [sys/mod.ts:2062](https://github.com/maiyunnet/kebab/blob/master/sys
138746
138786
 
138747
138787
  > **field**: `string`
138748
138788
 
138749
- Defined in: [sys/mod.ts:2063](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2063)
138789
+ Defined in: [sys/mod.ts:2089](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2089)
138750
138790
 
138751
138791
  ***
138752
138792
 
@@ -138754,7 +138794,7 @@ Defined in: [sys/mod.ts:2063](https://github.com/maiyunnet/kebab/blob/master/sys
138754
138794
 
138755
138795
  > `optional` **where?**: `any`
138756
138796
 
138757
- Defined in: [sys/mod.ts:2064](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2064)
138797
+ Defined in: [sys/mod.ts:2090](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2090)
138758
138798
 
138759
138799
  sys/mod/interfaces/IRows.md
138760
138800
  ---
@@ -138767,7 +138807,7 @@ sys/mod/interfaces/IRows.md
138767
138807
 
138768
138808
  # Interface: IRows\<T\>
138769
138809
 
138770
- Defined in: [sys/mod.ts:2056](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2056)
138810
+ Defined in: [sys/mod.ts:2082](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2082)
138771
138811
 
138772
138812
  ## Extends
138773
138813
 
@@ -138785,7 +138825,7 @@ Defined in: [sys/mod.ts:2056](https://github.com/maiyunnet/kebab/blob/master/sys
138785
138825
 
138786
138826
  > `readonly` **length**: `number`
138787
138827
 
138788
- Defined in: [sys/mod.ts:2057](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2057)
138828
+ Defined in: [sys/mod.ts:2083](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2083)
138789
138829
 
138790
138830
  ## Methods
138791
138831
 
@@ -138793,7 +138833,7 @@ Defined in: [sys/mod.ts:2057](https://github.com/maiyunnet/kebab/blob/master/sys
138793
138833
 
138794
138834
  > **item**(`index`): `T`
138795
138835
 
138796
- Defined in: [sys/mod.ts:2058](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2058)
138836
+ Defined in: [sys/mod.ts:2084](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2084)
138797
138837
 
138798
138838
  #### Parameters
138799
138839
 
@@ -138811,7 +138851,7 @@ Defined in: [sys/mod.ts:2058](https://github.com/maiyunnet/kebab/blob/master/sys
138811
138851
 
138812
138852
  > **toArray**(): `Record`\<`string`, `any`\>[]
138813
138853
 
138814
- Defined in: [sys/mod.ts:2059](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2059)
138854
+ Defined in: [sys/mod.ts:2085](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L2085)
138815
138855
 
138816
138856
  #### Returns
138817
138857
 
package/index.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * --- 本文件用来定义每个目录实体地址的常量 ---
5
5
  */
6
6
  /** --- 当前系统版本号 --- */
7
- export declare const VER = "9.27.0";
7
+ export declare const VER = "9.27.1";
8
8
  /** --- 框架根目录,以 / 结尾 --- */
9
9
  export declare const ROOT_PATH: string;
10
10
  /** --- 框架的 LIB,以 / 结尾 --- */
package/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export const VER = '9.27.0';
8
+ export const VER = '9.27.1';
9
9
  // --- 服务端用的路径 ---
10
10
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
11
11
  /** --- /xxx/xxx --- */
package/lib/sql.d.ts CHANGED
@@ -194,7 +194,8 @@ export declare class Sql {
194
194
  private _whereDataPosition;
195
195
  /**
196
196
  * --- 筛选器 ---
197
- * --- 标量相等:'city': 'bj', 'type': '2' ---
197
+ * --- 等值条件:'city': 'bj';字符串、数字、布尔值、bigint、Date 和 Buffer 均作为单个参数 ---
198
+ * --- null 生成 IS NULL,数组生成 IN 条件 ---
198
199
  * --- 运算符条件:['type', '>', '1'] ---
199
200
  * --- 集合条件:['type', 'in', ['1', '2']] 或 'type': ['1', '2'] ---
200
201
  * --- 逻辑分组:'$or': [{'city': 'bj'}, {'city': 'sh'}, [['age', '>', '10']]] ---
package/lib/sql.js CHANGED
@@ -504,7 +504,8 @@ export class Sql {
504
504
  _whereDataPosition = [0, 0];
505
505
  /**
506
506
  * --- 筛选器 ---
507
- * --- 标量相等:'city': 'bj', 'type': '2' ---
507
+ * --- 等值条件:'city': 'bj';字符串、数字、布尔值、bigint、Date 和 Buffer 均作为单个参数 ---
508
+ * --- null 生成 IS NULL,数组生成 IN 条件 ---
508
509
  * --- 运算符条件:['type', '>', '1'] ---
509
510
  * --- 集合条件:['type', 'in', ['1', '2']] 或 'type': ['1', '2'] ---
510
511
  * --- 逻辑分组:'$or': [{'city': 'bj'}, {'city': 'sh'}, [['age', '>', '10']]] ---
@@ -700,11 +701,6 @@ export class Sql {
700
701
  // --- NULL 判断 ---
701
702
  sql += this.field(k) + ' IS NULL AND ';
702
703
  }
703
- else if (typeof v === 'string' || typeof v === 'number') {
704
- // --- 标量相等 ---
705
- sql += this.field(k) + ' = ' + this._placeholder() + ' AND ';
706
- data.push(v);
707
- }
708
704
  else if (lSqlValue.isJson(v)) {
709
705
  // --- JSON 相等 ---
710
706
  const result = this._processValue(v);
@@ -715,7 +711,7 @@ export class Sql {
715
711
  // --- 字段相等 ---
716
712
  sql += this.field(k) + ' = ' + this.field(v.value) + ' AND ';
717
713
  }
718
- else {
714
+ else if (Array.isArray(v)) {
719
715
  // --- IN 查询,如 'type': ['1', '2'] ---
720
716
  if (v.length > 0) {
721
717
  sql += this.field(k) + ' IN (';
@@ -739,6 +735,11 @@ export class Sql {
739
735
  sql += this.field(k) + ' IN (NULL) AND ';
740
736
  }
741
737
  }
738
+ else {
739
+ // --- 普通值使用等号比较,原值交给数据库驱动处理 ---
740
+ sql += this.field(k) + ' = ' + this._placeholder() + ' AND ';
741
+ data.push(v);
742
+ }
742
743
  }
743
744
  }
744
745
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "9.27.0",
3
+ "version": "9.27.1",
4
4
  "description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
5
5
  "type": "module",
6
6
  "keywords": [
package/sys/mod.d.ts CHANGED
@@ -43,6 +43,12 @@ export default class Mod {
43
43
  protected static _$table: string;
44
44
  /** --- 主键字段名 --- */
45
45
  protected static _$primary: string;
46
+ /**
47
+ * --- 表的分区字段名,如 ['time_push'] ---
48
+ * save、remove、refresh 默认会把这些字段加入 WHERE 条件,与主键一起查找记录。
49
+ * 读取记录后不要修改主键或分区字段;留空时只使用主键。
50
+ */
51
+ protected static _$partition: string[];
46
52
  /** --- 设置后将由 _keyGenerator 函数生成唯一字段 --- */
47
53
  protected static _$key: string;
48
54
  /** --- 自动 key 冲突目标:MySQL 为索引名;PGSQL 为唯一字段或字段数组,PG 留空使用 _$key,不支持部分或表达式索引 --- */
@@ -314,6 +320,11 @@ export default class Mod {
314
320
  * @param obj 要转换的 kv 数据列表
315
321
  */
316
322
  static toArrayByRecord<T extends Mod>(obj: Record<string, T>): Record<string, Record<string, any>>;
323
+ /**
324
+ * --- 构造包含主键和分区字段的 WHERE 条件 ---
325
+ * @returns 主键及分区字段条件,缺少字段时返回 false
326
+ */
327
+ private _getIdentityWhere;
317
328
  /**
318
329
  * --- 设置单个模型属性,并记录是否需要在数据库边界序列化 ---
319
330
  * @param key 字段名
@@ -348,16 +359,18 @@ export default class Mod {
348
359
  /**
349
360
  * --- 刷新当前模型获取最新数据 ---
350
361
  * @param lock 是否加锁
362
+ * @returns true 成功,null 记录不存在,false 缺少定位字段或查询失败
351
363
  */
352
364
  refresh(lock?: boolean): Promise<boolean | null>;
353
365
  /**
354
366
  * --- 更新 set 的数据到数据库,有未保存数据时才保存 ---
355
- * @param where 非空筛选条件,省略时必须有主键
356
- * @returns 是否成功,失败保留待写数据
367
+ * @param where 显式非空筛选条件;省略时使用主键和分区字段值
368
+ * @returns 是否成功,缺少默认定位字段或写入失败返回 false 并保留待写数据
357
369
  */
358
370
  save(where?: any): Promise<boolean>;
359
371
  /**
360
- * --- 移除本条目 ---
372
+ * --- 按主键和分区字段删除当前记录 ---
373
+ * @returns 是否成功,缺少定位字段、记录不存在或删除失败返回 false
361
374
  */
362
375
  remove(): Promise<boolean>;
363
376
  first(lock: boolean, array: true): Promise<false | null | Record<string, any>>;
package/sys/mod.js CHANGED
@@ -51,6 +51,12 @@ export default class Mod {
51
51
  static _$table = '';
52
52
  /** --- 主键字段名 --- */
53
53
  static _$primary = 'id';
54
+ /**
55
+ * --- 表的分区字段名,如 ['time_push'] ---
56
+ * save、remove、refresh 默认会把这些字段加入 WHERE 条件,与主键一起查找记录。
57
+ * 读取记录后不要修改主键或分区字段;留空时只使用主键。
58
+ */
59
+ static _$partition = [];
54
60
  /** --- 设置后将由 _keyGenerator 函数生成唯一字段 --- */
55
61
  static _$key = '';
56
62
  /** --- 自动 key 冲突目标:MySQL 为索引名;PGSQL 为唯一字段或字段数组,PG 留空使用 _$key,不支持部分或表达式索引 --- */
@@ -551,6 +557,25 @@ export default class Mod {
551
557
  return rtn;
552
558
  }
553
559
  // --- 动态方法 ---
560
+ /**
561
+ * --- 构造包含主键和分区字段的 WHERE 条件 ---
562
+ * @returns 主键及分区字段条件,缺少字段时返回 false
563
+ */
564
+ _getIdentityWhere() {
565
+ const cstr = this.constructor;
566
+ if (!cstr._$partition.length) {
567
+ return this._data[cstr._$primary] ? { [cstr._$primary]: this._data[cstr._$primary] } : false;
568
+ }
569
+ const where = {};
570
+ for (const field of new Set([cstr._$primary, ...cstr._$partition])) {
571
+ const value = this._data[field];
572
+ if (value === undefined || (field === cstr._$primary && value === null)) {
573
+ return false;
574
+ }
575
+ where[field] = value;
576
+ }
577
+ return where;
578
+ }
554
579
  /**
555
580
  * --- 设置单个模型属性,并记录是否需要在数据库边界序列化 ---
556
581
  * @param key 字段名
@@ -735,7 +760,7 @@ export default class Mod {
735
760
  }
736
761
  const mysql = this._db.getService() === lDb.ESERVICE.MYSQL;
737
762
  const table = cstr._$table + (this._index ? `_${this._index[0]}` : '');
738
- const identity = [...new Set([cstr._$primary, cstr._$key].filter(field => field))];
763
+ const identity = [...new Set([cstr._$primary, cstr._$key, ...cstr._$partition].filter(field => field))];
739
764
  if (mysql) {
740
765
  const created = await this.create();
741
766
  if (created !== null) {
@@ -782,16 +807,16 @@ export default class Mod {
782
807
  /**
783
808
  * --- 刷新当前模型获取最新数据 ---
784
809
  * @param lock 是否加锁
810
+ * @returns true 成功,null 记录不存在,false 缺少定位字段或查询失败
785
811
  */
786
812
  async refresh(lock = false) {
787
813
  const cstr = this.constructor;
788
- if (!this._data[cstr._$primary]) {
789
- lCore.log(this._ctr ?? {}, '[MOD][refresh] primary key not found', '-error');
814
+ const where = this._getIdentityWhere();
815
+ if (where === false) {
816
+ lCore.log(this._ctr ?? {}, '[MOD][refresh] primary or partition field not loaded', '-error');
790
817
  return false;
791
818
  }
792
- this._sql.select('*', cstr._$table + (this._index ? ('_' + this._index[0]) : '')).where([{
793
- [cstr._$primary]: this._data[cstr._$primary]
794
- }]);
819
+ this._sql.select('*', cstr._$table + (this._index ? ('_' + this._index[0]) : '')).where(where);
795
820
  if (lock) {
796
821
  this._sql.lock();
797
822
  }
@@ -812,24 +837,23 @@ export default class Mod {
812
837
  }
813
838
  /**
814
839
  * --- 更新 set 的数据到数据库,有未保存数据时才保存 ---
815
- * @param where 非空筛选条件,省略时必须有主键
816
- * @returns 是否成功,失败保留待写数据
840
+ * @param where 显式非空筛选条件;省略时使用主键和分区字段值
841
+ * @returns 是否成功,缺少默认定位字段或写入失败返回 false 并保留待写数据
817
842
  */
818
843
  async save(where) {
819
844
  if (Object.keys(this._updates).length === 0) {
820
845
  return true;
821
846
  }
822
847
  const cstr = this.constructor;
823
- if (!this._data[cstr._$primary] && (where === undefined || where === null)) {
824
- lCore.log(this._ctr ?? {}, '[MOD][save] primary key not found', '-error');
848
+ const filter = where ?? this._getIdentityWhere();
849
+ if (filter === false) {
850
+ lCore.log(this._ctr ?? {}, '[MOD][save] primary or partition field not loaded', '-error');
825
851
  return false;
826
852
  }
827
853
  const updates = this._getUpdates();
828
854
  this._sql.update(cstr._$table + (this._index ? ('_' + this._index[0]) : ''), [updates]);
829
855
  const updateSql = this._sql.getSql();
830
- this._sql.where(where ?? {
831
- [cstr._$primary]: this._data[cstr._$primary]
832
- });
856
+ this._sql.where(filter);
833
857
  if (this._sql.getSql() === updateSql) {
834
858
  return false;
835
859
  }
@@ -848,17 +872,17 @@ export default class Mod {
848
872
  }
849
873
  }
850
874
  /**
851
- * --- 移除本条目 ---
875
+ * --- 按主键和分区字段删除当前记录 ---
876
+ * @returns 是否成功,缺少定位字段、记录不存在或删除失败返回 false
852
877
  */
853
878
  async remove() {
854
879
  const cstr = this.constructor;
855
- if (!this._data[cstr._$primary]) {
856
- lCore.log(this._ctr ?? {}, '[MOD][remove] primary key not found', '-error');
880
+ const where = this._getIdentityWhere();
881
+ if (where === false) {
882
+ lCore.log(this._ctr ?? {}, '[MOD][remove] primary or partition field not loaded', '-error');
857
883
  return false;
858
884
  }
859
- this._sql.delete(cstr._$table + (this._index ? ('_' + this._index[0]) : '')).where([{
860
- [cstr._$primary]: this._data[cstr._$primary]
861
- }]);
885
+ this._sql.delete(cstr._$table + (this._index ? ('_' + this._index[0]) : '')).where(where);
862
886
  const r = await this._db.execute(this._sql.getSql(), this._sql.getData());
863
887
  if (r.packet === null) {
864
888
  lCore.log(this._ctr ?? {}, '[MOD][remove] ' + (lText.stringifyJson(r.error?.message ?? '').slice(1, -1) + ' - ' + this._sql.format()).replaceAll('"', '""'), '-error');