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;
|
||||
}
|
||||
|
||||
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: {
|
||||
baseId: string;
|
||||
workspaceId: string;
|
||||
@@ -217,6 +232,26 @@ export class BaseRowRepo {
|
||||
.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(
|
||||
baseId: string,
|
||||
propertyId: string,
|
||||
|
||||
Reference in New Issue
Block a user