refactor(yachts): use withTransaction helper per project convention
This commit is contained in:
@@ -5,6 +5,7 @@ import { companies } from '@/lib/db/schema/companies';
|
||||
import { createAuditLog } from '@/lib/audit';
|
||||
import { NotFoundError, ValidationError } from '@/lib/errors';
|
||||
import { emitToRoom } from '@/lib/socket/server';
|
||||
import { withTransaction } from '@/lib/db/utils';
|
||||
import type { z } from 'zod';
|
||||
import type { createYachtSchema } from '@/lib/validators/yachts';
|
||||
|
||||
@@ -36,8 +37,8 @@ async function assertOwnerExists(
|
||||
}
|
||||
|
||||
export async function createYacht(portId: string, data: CreateYachtInput, meta: AuditMeta) {
|
||||
return await db.transaction(async (tx) => {
|
||||
await assertOwnerExists(portId, data.owner, tx as unknown as typeof db);
|
||||
return await withTransaction(async (tx) => {
|
||||
await assertOwnerExists(portId, data.owner, tx);
|
||||
|
||||
const [yacht] = await tx
|
||||
.insert(yachts)
|
||||
|
||||
Reference in New Issue
Block a user