-
I'm trying to use HasManyBy in TypeScript in one store where I plan to store IDs of associated catalogs in array. export default class Referee extends Model {
static entity = 'referees'
@Str( '' ) declare id: string
@Str( '' ) declare name: string
@Attr( '[]' ) @Cast( () => ArrayCast ) declare titleIds: number[]
@HasManyBy( () => RefereeTitle, 'titleIds' ) declare titles: RefereeTitle[]
} and there is also catalog model for titles: export default class RefereeTitle extends Model {
static entity = 'referee-titles'
@Num( 0 ) declare id: number
@Str( '' ) declare title: string
} But when I filling Example of one referee: Referee { id: '0001', name: 'John Doe', titleIds: Array(1) }
RefereeTitle { id: 20, title: 'Main referee' } Access to Any help how to correctly use Thanks in advance. BTW it is hard to prepare working example in prepared bug environment due to possibility create only JS or TS.VUE files, not pure TS models :-( But that is another story. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
According to https://pinia-orm.codedredd.de/guide/model/decorators also tested without casting @Attr( null ) declare titleIds: number[] But same result :( Only dump shows |
Beta Was this translation helpful? Give feedback.
-
Ohh, I have to call repository with |
Beta Was this translation helpful? Give feedback.
Ohh, I have to call repository with
with
for that accessor filled. But I am trying to access it from model itself and there is nowith
possibility. So it is obvious why it is not working now, I can close it. Sorry for bother all.