const prisma = require("./client") async function findDeals(where = {}, options = {}) { return prisma.deal.findMany({ where, include: options.include || undefined, select: options.select || undefined, orderBy: options.orderBy || { createdAt: "desc" }, skip: options.skip || 0, take: options.take || undefined, }) } async function findDeal(where, options = {}) { return prisma.deal.findUnique({ where, include: options.include || undefined, select: options.select || undefined, }) } async function createDeal(data, options = {}) { return prisma.deal.create({ data, include: options.include || undefined, select: options.select || undefined, }) } async function updateDeal(where, data, options = {}) { return prisma.deal.update({ where, data, include: options.include || undefined, select: options.select || undefined, }) } async function countDeals(where = {}) { return prisma.deal.count({ where }) } async function findVotes(where = {}, options = {}) { return prisma.dealVote.findMany({ where, include: options.include || undefined, select: options.select || undefined, }) } async function createVote(data, options = {}) { return prisma.dealVote.create({ data, include: options.include || undefined, select: options.select || undefined, }) } async function updateVote(where, data, options = {}) { return prisma.dealVote.update({ where, data, include: options.include || undefined, select: options.select || undefined, }) } async function countVotes(where = {}) { return prisma.dealVote.count({ where }) } module.exports = { findDeals, findDeal, createDeal, updateDeal, countDeals, findVotes, createVote, updateVote, countVotes, }