Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

323
Views
¿Cómo puedo actualizar un campo en Prisma usando Next.js?

Quiero actualizar el campo de tasks usando Prisma para mi base de datos PlanetScale, ¿cómo puedo hacerlo?

Aquí está el código del archivo schema.prisma ,

 generator client { provider = "prisma-client-js" previewFeatures = ["referentialIntegrity"] } datasource db { provider = "mysql" url = env("DATABASE_URL") referentialIntegrity = "prisma" } model User{ id Int @default(autoincrement()) @id uid String @unique tasks String @default("[]") createdAt DateTime @default(now()) secretKey String @default(cuid()) @unique }

Y aquí está mi código fuente de API Next.js,

 import { PrismaClient } from "@prisma/client"; const prisma = new PrismaClient(); export default async function handler(req, res){ if(req.method === 'POST'){ return await createTask(req, res); }else{ res.status(405).json({ message: 'Method not allowed', success: false }) } } async function createTask(req, res){ const { userId } = req.body; try{ const body = req.body; // update the user's task list const user = await prisma.user.update({ where: { uid: userId }, data: { tasks: body.value } }) res.status(200).json({ message: 'Task created', success: true }) }catch (error) { console.error("Request error", error); res.status(500).json({ error: "Error creating tasks", success:false }); } }

Por favor guíame para resolver este problema.

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!