server: refactor pagination

* fix transaction usgae in repos
* other bug fixes
This commit is contained in:
Philipinho
2024-04-01 01:23:52 +01:00
parent ade3a5b589
commit 4913975e99
38 changed files with 648 additions and 756 deletions
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { InjectKysely } from 'nestjs-kysely';
import { KyselyDB, KyselyTransaction } from '@docmost/db/types/kysely.types';
import { executeTx } from '@docmost/db/utils';
import { dbOrTx } from '@docmost/db/utils';
import {
Attachment,
InsertableAttachment,
@@ -28,17 +28,13 @@ export class AttachmentRepo {
insertableAttachment: InsertableAttachment,
trx?: KyselyTransaction,
): Promise<Attachment> {
return await executeTx(
this.db,
async (trx) => {
return await trx
.insertInto('attachments')
.values(insertableAttachment)
.returningAll()
.executeTakeFirst();
},
trx,
);
const db = dbOrTx(this.db, trx);
return db
.insertInto('attachments')
.values(insertableAttachment)
.returningAll()
.executeTakeFirst();
}
async updateAttachment(