mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
feat(base): add findByIds and softDeleteMany to base-row repo
This commit is contained in:
@@ -59,6 +59,21 @@ export class BaseRowRepo {
|
|||||||
.executeTakeFirst()) as BaseRow | undefined;
|
.executeTakeFirst()) as BaseRow | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findByIds(
|
||||||
|
rowIds: string[],
|
||||||
|
opts: WorkspaceOpts,
|
||||||
|
): Promise<BaseRow[]> {
|
||||||
|
if (rowIds.length === 0) return [];
|
||||||
|
const db = dbOrTx(this.db, opts.trx);
|
||||||
|
return (await db
|
||||||
|
.selectFrom('baseRows')
|
||||||
|
.select(BASE_ROW_COLUMNS)
|
||||||
|
.where('id', 'in', rowIds)
|
||||||
|
.where('workspaceId', '=', opts.workspaceId)
|
||||||
|
.where('deletedAt', 'is', null)
|
||||||
|
.execute()) as BaseRow[];
|
||||||
|
}
|
||||||
|
|
||||||
async list(opts: {
|
async list(opts: {
|
||||||
baseId: string;
|
baseId: string;
|
||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
@@ -217,6 +232,26 @@ export class BaseRowRepo {
|
|||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async softDeleteMany(
|
||||||
|
rowIds: string[],
|
||||||
|
opts: {
|
||||||
|
baseId: string;
|
||||||
|
workspaceId: string;
|
||||||
|
trx?: KyselyTransaction;
|
||||||
|
},
|
||||||
|
): Promise<void> {
|
||||||
|
if (rowIds.length === 0) return;
|
||||||
|
const db = dbOrTx(this.db, opts.trx);
|
||||||
|
await db
|
||||||
|
.updateTable('baseRows')
|
||||||
|
.set({ deletedAt: new Date() })
|
||||||
|
.where('id', 'in', rowIds)
|
||||||
|
.where('baseId', '=', opts.baseId)
|
||||||
|
.where('workspaceId', '=', opts.workspaceId)
|
||||||
|
.where('deletedAt', 'is', null)
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
async removeCellKey(
|
async removeCellKey(
|
||||||
baseId: string,
|
baseId: string,
|
||||||
propertyId: string,
|
propertyId: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user