Open anhc0de opened 8 months ago
20.4.0
I have set up relationships as below
User.ts
@hasMany(() => Task, { foreignKey: 'assignedToId', }) declare assignedTasks: HasMany<typeof Task>
Task.ts
@column({ columnName: 'assigned_to_id' }) declare assignedToId: number @belongsTo(() => User, { foreignKey: 'assignedToId', }) declare assignedTo: BelongsTo<typeof User>
Query
const records = await Task.query() .preload('assignedTo') .orderBy('updated_at', 'desc') .orderBy('created_at', 'desc') .paginate(page, limit) records.forEach((user) => { logger.info('assignedToId=%s preload::assignedTo=%o', user.assignedToId, user.assignedTo) })
Result
DB tables
User
Task
No response
Package version
20.4.0
Describe the bug
I have set up relationships as below
User.ts
Task.ts
Query
Result
DB tables
User
Task
Reproduction repo
No response