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

176
Views
¿Cómo se encuentra la existencia de registros de niños (Adonis Lucid Many-to-Many) en un padre que cumple con un criterio?

Estoy tratando de encontrar la existencia de ciertos permisos en un solo rol principal (muchos a muchos).

 const roles = await Role .query() .preload('permissions') this.role = roles.find(role => role.id === someid) const exists = this.role.permissions.some(permission => permission.name === 'something')

Esta es la solución hasta ahora, que no parece óptima. ¿Hay alguna manera de hacer esto sin cargar todos los roles y permisos y recorrerlos en Javascript? Muchas gracias

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Intente usar whereHas ( https://docs.adonisjs.com/reference/orm/query-builder#wherehas ):

 await Role.query() .where('id', someid) .whereHas('permissions', q => { q.where('name', 'something') })
about 4 years ago · Juan Pablo Isaza Report
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!