intern-Assignment/Assignment-Validation/blog-crud/index.js

57 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2025-01-31 09:50:39 +00:00
// const { PrismaClient } = require('@prisma/client');
// const prisma = new PrismaClient();
// async function main() {
// await prisma.blog.create({
// data: {
// slug: 'Hello World-90',
// title: 'It is working',
// body: 'Hello It is working...',
// categoryIDs: [],
// tagIDs: [],
// },
// })
// const allBlogs = await prisma.blog.findMany({
// include: {
// comments: true,
// categories: true,
// tags: true,
// },
// })
// console.dir(allBlogs, { depth: null })
// }
// main()
// .catch(async (e) => {
// console.error(e)
// process.exit(1)
// })
// .finally(async () => {
// await prisma.$disconnect()
// })
// async function createBlog(data) {
// return await prisma.blog.create({ data });
// }
// async function getBlogs() {
// return await prisma.blog.findMany({
// include: { comments: true, categories: true, tags: true },
// });
// }
// async function updateBlog(id, data) {
// return await prisma.blog.update({
// where: { id },
// data,
// });
// }
// async function deleteBlog(id) {
// return await prisma.blog.delete({ where: { id } });
// }
// module.exports = { createBlog, getBlogs, updateBlog, deleteBlog };