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

134
Views
Adonis js loading only first preload

Im trying to list the itens of Chamados and the respective users, but only the first chamado return the user.

Model Usuario:

  export default class Usuario extends BaseModel {
  @hasMany(() => Chamado)
  public chamados: HasMany<typeof Chamado>

  @column({ isPrimary: true })
  public id: number

  @column()
  public nome: string

  @column()
  public nivel: number

  @column()
  public email: string

  @column()
  public senha: string

  @column.dateTime({ autoCreate: true })
  public createdAt: DateTime

  @column.dateTime({ autoCreate: true, autoUpdate: true })
  public updatedAt: DateTime
}

Model Chamado:

export default class Chamado extends BaseModel {
  @belongsTo(() => Usuario, {
    foreignKey: 'id'
  })
  public user: BelongsTo<typeof Usuario>

  @column({ isPrimary: true })
  public id: number

  @column()
  public titulo: string

  @column()
  public descricao: string

  @column()
  public url_erro: string

ChamadosController

 // Get chamados
    public async index() {
        const chamados = await Chamado.query().preload('user')

        return {
            data: chamados,
        }
    }

is returning 'user' only in first result: result from get

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!