From 396acf3bbbe00a192cb0ea0a9ccf91b1d8d2850b Mon Sep 17 00:00:00 2001 From: Fuwn <50817549+Fuwn@users.noreply.github.com> Date: Sat, 24 Jan 2026 13:09:50 +0000 Subject: Initial commit Created from https://vercel.com/new --- src/queries/prisma/pixel.ts | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/queries/prisma/pixel.ts (limited to 'src/queries/prisma/pixel.ts') diff --git a/src/queries/prisma/pixel.ts b/src/queries/prisma/pixel.ts new file mode 100644 index 0000000..4c9e132 --- /dev/null +++ b/src/queries/prisma/pixel.ts @@ -0,0 +1,60 @@ +import type { Prisma } from '@/generated/prisma/client'; +import prisma from '@/lib/prisma'; +import type { QueryFilters } from '@/lib/types'; + +export async function findPixel(criteria: Prisma.PixelFindUniqueArgs) { + return prisma.client.pixel.findUnique(criteria); +} + +export async function getPixel(pixelId: string) { + return findPixel({ + where: { + id: pixelId, + }, + }); +} + +export async function getPixels(criteria: Prisma.PixelFindManyArgs, filters: QueryFilters = {}) { + const { search } = filters; + + const where: Prisma.PixelWhereInput = { + ...criteria.where, + ...prisma.getSearchParameters(search, [{ name: 'contains' }, { slug: 'contains' }]), + }; + + return prisma.pagedQuery('pixel', { ...criteria, where }, filters); +} + +export async function getUserPixels(userId: string, filters?: QueryFilters) { + return getPixels( + { + where: { + userId, + }, + }, + filters, + ); +} + +export async function getTeamPixels(teamId: string, filters?: QueryFilters) { + return getPixels( + { + where: { + teamId, + }, + }, + filters, + ); +} + +export async function createPixel(data: Prisma.PixelUncheckedCreateInput) { + return prisma.client.pixel.create({ data }); +} + +export async function updatePixel(pixelId: string, data: any) { + return prisma.client.pixel.update({ where: { id: pixelId }, data }); +} + +export async function deletePixel(pixelId: string) { + return prisma.client.pixel.delete({ where: { id: pixelId } }); +} -- cgit v1.2.3