release: v0.5.1 — 存储后端生产级硬化(CRC-32/全库加密/WAL分片/页面化存储/多标签页锁/e2e)+ 深度审查修复(假实现接线/死代码清理)
CI / test (18.x) (push) Successful in 10m10s
CI / test (20.x) (push) Successful in 10m10s
CI / test (22.x) (push) Successful in 10m6s
CI / e2e (push) Successful in 9m51s
CI / test (24.x) (push) Successful in 10m28s

This commit is contained in:
thzxx
2026-08-10 12:07:00 +08:00
parent cff98b0903
commit 334067d89e
88 changed files with 15713 additions and 10626 deletions
+16 -2
View File
@@ -135,14 +135,18 @@ export class SelectQueryBuilder {
export class UpdateQueryBuilder {
private _where: WhereCondition = {};
private onWrite?: (table: string) => void;
/** v0.5.1: CRUD hooks 触发回调 */
private onHooks?: (hook: import('../constants').HookName, args: unknown[]) => Promise<void>;
constructor(
private engine: IStorageEngine,
private tableName: string,
private _updates: Record<string, unknown>,
onWrite?: (table: string) => void,
onHooks?: (hook: import('../constants').HookName, args: unknown[]) => Promise<void>,
) {
this.onWrite = onWrite;
this.onHooks = onHooks;
}
where(condition: WhereCondition): this {
@@ -151,8 +155,11 @@ export class UpdateQueryBuilder {
}
async execute(): Promise<number> {
const count = await this.engine.update(this.tableName, { table: this.tableName, where: this._where }, this._updates);
const query = { table: this.tableName, where: this._where };
await this.onHooks?.('beforeUpdate', [query, this._updates]);
const count = await this.engine.update(this.tableName, query, this._updates);
this.onWrite?.(this.tableName);
await this.onHooks?.('afterUpdate', [query, this._updates, count]);
return count;
}
@@ -168,13 +175,17 @@ export class UpdateQueryBuilder {
export class DeleteQueryBuilder {
private _where: WhereCondition = {};
private onWrite?: (table: string) => void;
/** v0.5.1: CRUD hooks 触发回调 */
private onHooks?: (hook: import('../constants').HookName, args: unknown[]) => Promise<void>;
constructor(
private engine: IStorageEngine,
private tableName: string,
onWrite?: (table: string) => void,
onHooks?: (hook: import('../constants').HookName, args: unknown[]) => Promise<void>,
) {
this.onWrite = onWrite;
this.onHooks = onHooks;
}
where(condition: WhereCondition): this {
@@ -183,8 +194,11 @@ export class DeleteQueryBuilder {
}
async execute(): Promise<number> {
const count = await this.engine.delete(this.tableName, { table: this.tableName, where: this._where });
const query = { table: this.tableName, where: this._where };
await this.onHooks?.('beforeDelete', [query]);
const count = await this.engine.delete(this.tableName, query);
this.onWrite?.(this.tableName);
await this.onHooks?.('afterDelete', [query, count]);
return count;
}