Closed nelsonjd closed 1 year ago
Nested Preload function under belongsTo preload is not running.
"@adonisjs/auth": "^8.2.3", "@adonisjs/bouncer": "^2.3.0", "@adonisjs/core": "^5.9.0", "@adonisjs/lucid": "^18.3.0", "@adonisjs/mail": "^7.2.4", "@adonisjs/repl": "^3.1.6", "@adonisjs/session": "^6.4.0", "@adonisjs/view": "^6.1.0",
% node -v v16.16.0 % npm -v 8.11.0
const strategy = await StrategyRepository.findByUidForUser(params.strategyId)
public findByUidForUser(uid: string) { return Strategy.query() .where('uid', uid) .preload('account', (accountQuery) => { console.log('i ran') accountQuery.preload('users') }) .firstOrFail() }
i ran is not being printed.
select * from "Strategies" where "uid" = ? limit ? [ 'btQ3a', 1 ] select * from "Accounts" where "id" in (?) [ 1 ]
are SQL outputs
Strategy.ts
@column() public accountId: number @belongsTo(() => Account) public account: BelongsTo<typeof Account>
Account.ts
@manyToMany(() => User, { pivotTable: 'UserAccounts', pivotForeignKey: 'accountId', pivotRelatedForeignKey: 'userId', }) public users: ManyToMany<typeof User>
Hi, do you try to put first preload instead of where statement?
Please open issues in the correct repo
Nested Preload function under belongsTo preload is not running.
Package version
Node.js and npm version
% node -v v16.16.0 % npm -v 8.11.0
Sample Code (to reproduce the issue)
i ran is not being printed.
are SQL outputs
Strategy.ts
Account.ts
BONUS (a sample repo to reproduce the issue)