mirror of
https://github.com/docmost/docmost.git
synced 2025-11-19 01:21:14 +10:00
more work on attachments
* fix frontend env usage
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user