added tons of features

This commit is contained in:
2025-02-05 08:01:14 +02:00
parent 4ae0d8c545
commit 8138da6b1d
195 changed files with 12619 additions and 415 deletions

View File

@@ -0,0 +1,50 @@
'use server'
import {Lang, Product, ProductLocale} from '@prisma/client'
import internal from 'node:stream'
import {db, dbQueryLog} from '@/lib/db/prisma/client'
export const getProductBySlug = async (data: {
slug: string
lang: string
}): Promise<ProductLocale | null> => {
return db.productLocale.findFirst({
where: {
slug: data.slug,
lang: data.lang as Lang
}
})
}
export const getProductById = async (id: unknown): Promise<Product | null> => {
return db.product.findUnique({
where: {id: id as number},
include: {
locales: {
include: {
meta: true
}
},
toStore: true
}
})
}
export const getProducts = async (): Promise<Product[] | null> => {
return db.product.findMany({
include: {
locales: {
omit: {
description: true,
content: true,
instruction: true
},
include: {
meta: true
}
},
toStore: true
}
})
}