import { prismaClient } from '../database/prismaClient.js';
export async function createTransaction(data) {
    console.log(`Creating transaction for chat: ${data.chat.connect?.id} and message: ${data.message.connect?.messageId}`);
    return prismaClient.transaction.create({
        data,
    });
}
export async function getTransaction(chatId, messageId) {
    console.log(`Getting transaction for chat ${chatId} and message ${messageId}`);
    return prismaClient.transaction.findUnique({
        where: {
            chatId_messageId: {
                chatId: chatId,
                messageId: messageId,
            },
        },
    });
}
export async function getTransactionsByChatId(chatId) {
    console.log(`Getting all transactions for chat ${chatId}`);
    return prismaClient.transaction.findMany({
        where: {
            chatId: chatId,
        },
    });
}
export async function listTransactions() {
    console.log('Listing all transactions');
    return prismaClient.transaction.findMany();
}
export async function updateTransaction(chatId, messageId, data) {
    console.log(`Updating transaction for chat ${chatId} and message ${messageId}`);
    return prismaClient.transaction.update({
        where: {
            chatId_messageId: {
                chatId: chatId,
                messageId: messageId,
            },
        },
        data,
    });
}
export async function deleteTransaction(chatId, messageId) {
    console.log(`Deleting transaction for chat ${chatId} and message ${messageId}`);
    return prismaClient.transaction.delete({
        where: {
            chatId_messageId: {
                chatId: chatId,
                messageId: messageId,
            },
        },
    });
}
