/
review
/
bot
Обзор
Документация
Войти
/
review
/
bot
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
src/database/models/TestDetail/methods/methods.ts
49 строк
1 KB
Semyon Okulov
init
28 июл 2025, 09:49
28 июл 2025, 09:49
874de44
Код
Авторство
О чём код?
import { eq } from 'drizzle-orm' import type { Tx } from '@database' import type { TestDetailRepository } from '../repository.ts' import { testDetails } from '../schema.ts' import type { TestDetail, TestId } from '../type.ts' /** * Создает детализацию теста */ export async function create( this: TestDetailRepository, data: Omit<TestDetail, 'id'>, tx?: Tx ): Promise<TestDetail> { const executor = tx ?? this.db const [newTestDetail] = await executor .insert(testDetails) .values(data) .returning() return newTestDetail } /** * Получает детализации по идентификатору теста */ export async function findByTestId( this: TestDetailRepository, testId: TestId, tx?: Tx ): Promise<TestDetail[]> { const executor = tx ?? this.db return executor.query.testDetails.findMany({ where: eq(testDetails.testId, testId) }) } /** * Удаляет детализации по идентификатору теста */ export async function deleteByTestId( this: TestDetailRepository, testId: TestId, tx?: Tx ): Promise<void> { const executor = tx ?? this.db await executor.delete(testDetails).where(eq(testDetails.testId, testId)) }