more work on attachments

* fix frontend env usage
This commit is contained in:
Philipinho
2024-05-22 23:24:57 +01:00
parent b06a78b6ec
commit ccf9d5d99f
31 changed files with 612 additions and 349 deletions

View File

@ -14,13 +14,16 @@ export class AttachmentRepo {
async findById(
attachmentId: string,
workspaceId: string,
opts?: {
trx?: KyselyTransaction;
},
): Promise<Attachment> {
return this.db
const db = dbOrTx(this.db, opts?.trx);
return db
.selectFrom('attachments')
.selectAll()
.where('id', '=', attachmentId)
.where('workspaceId', '=', workspaceId)
.executeTakeFirst();
}
@ -48,4 +51,18 @@ export class AttachmentRepo {
.returningAll()
.executeTakeFirst();
}
async deleteAttachment(attachmentId: string): Promise<void> {
await this.db
.deleteFrom('attachments')
.where('id', '=', attachmentId)
.executeTakeFirst();
}
async deleteAttachmentByFilePath(attachmentFilePath: string): Promise<void> {
await this.db
.deleteFrom('attachments')
.where('filePath', '=', attachmentFilePath)
.executeTakeFirst();
}
}