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

126
Views
Consulta para obtener el músico más popular con una suma de campo agregada

Tengo el siguiente esquema de base de datos:

 model Music { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt title String @db.VarChar(255) duration Int playbacks Int artist Musician? @relation(fields: [musicianId], references: [id]) artistId Int? } model Musician { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt name String? musics Music[] albums Album[] }

Y tengo que devolver 3 músicos más populares con un campo agregado totalPlaybacks en cada uno.

¿Es posible hacer esto usando findMany en prisma?

Este es mi controlador:

 exports.getTopThree = (req, res) => { prisma.artist .findMany({ //should the query be there }) .then((data) => { console.log(data); res.send({ data }); }) .catch((err) => { res.status(500).send({ message: err.message || "Some error occurred while retrieving artists.", }); }); };

¿Alguien podría ayudarme con este problema?

about 4 years ago · Juan Pablo Isaza
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!