updates and fixes

* seo friendly urls
* custom client serve-static module
* database fixes
* fix recent pages
* other fixes
This commit is contained in:
Philipinho
2024-05-18 03:19:42 +01:00
parent eefe63d1cd
commit 9c7c2f1163
102 changed files with 921 additions and 536 deletions

View File

@ -0,0 +1,51 @@
import { Injectable } from '@nestjs/common';
import { InjectKysely } from 'nestjs-kysely';
import { KyselyDB, KyselyTransaction } from '@docmost/db/types/kysely.types';
import { dbOrTx } from '@docmost/db/utils';
import {
Attachment,
InsertableAttachment,
UpdatableAttachment,
} from '@docmost/db/types/entity.types';
@Injectable()
export class AttachmentRepo {
constructor(@InjectKysely() private readonly db: KyselyDB) {}
async findById(
attachmentId: string,
workspaceId: string,
): Promise<Attachment> {
return this.db
.selectFrom('attachments')
.selectAll()
.where('id', '=', attachmentId)
.where('workspaceId', '=', workspaceId)
.executeTakeFirst();
}
async insertAttachment(
insertableAttachment: InsertableAttachment,
trx?: KyselyTransaction,
): Promise<Attachment> {
const db = dbOrTx(this.db, trx);
return db
.insertInto('attachments')
.values(insertableAttachment)
.returningAll()
.executeTakeFirst();
}
async updateAttachment(
updatableAttachment: UpdatableAttachment,
attachmentId: string,
): Promise<void> {
await this.db
.updateTable('attachments')
.set(updatableAttachment)
.where('id', '=', attachmentId)
.returningAll()
.executeTakeFirst();
}
}