export async function updatePageViews(
postSlug: string,
title: string,
category: string
) {
try {
const existingPost = await db.post.findUnique({
where: { slug: postSlug },
});
if (existingPost) {
await db.post.update({
where: { slug: postSlug },
data: {
view_count: { increment: 1 },
},
});
} else {
await db.post.create({
data: {
slug: postSlug,
title: title,
category: category,
},
});
}
} catch (error) {
console.error("Error updating page view:", error);
}
}
export async function updatePageViews(
postSlug: string,
title: string,
category: string
) {
try {
const existingPost = await db.post.findUnique({
where: { slug: postSlug },
});
if (existingPost) {
await db.post.update({
where: { slug: postSlug },
data: {
view_count: { increment: 1 },
},
});
} else {
await db.post.create({
data: {
slug: postSlug,
title: title,
category: category,
},
});
}
} catch (error) {
console.error("Error updating page view:", error);
}
}