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

182
Views
Objection JS obtiene propiedades adicionales de la tabla unida + filtro

Tengo el siguiente modelo:

 class Profile extends Model { ....................... static relationMappings = { finishers: { relation: Model.ManyToManyRelation, modelClass: Move, filter: (query) => query.select('move.id', 'move.type'), join: { from: 'profile.id', through: { from: 'profile_move.profile_id', to: 'profile_move.move_id', extra: { alternative_name: 'name', }, }, to: 'move.id', }, }, }; }

Lo que estoy tratando de hacer es obtener solo move.id y move.type de la tabla de move y también el name de propiedad adicional de la tabla unida profile_move . El problema es que si uso un filter o un modificador, solo devuelve move.id y move.type y no la propiedad adicional.

Ruta:

 router.get('/', async (req, res, next) => { try { const data = await Profile.query() .orderBy('id') .withGraphFetched('finishers'); res.json(data); } catch (error) { next(error); } });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La solución es pasar la propiedad extra para filtrar:

 filter: (query) => query.select('move.id', 'move.type', 'profile_move.name'),
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!