Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relations dont show up in list, show and edit #18

Open
in-live-md opened this issue May 3, 2021 · 3 comments
Open

Relations dont show up in list, show and edit #18

in-live-md opened this issue May 3, 2021 · 3 comments

Comments

@in-live-md
Copy link

on ver 1.4.0: I followed README and defined @RelationId() on my relation entities - but i cant get any relations to show up in adminbro UI. I can edit resources and set relations - and i can see in my logs the update sql is correct, but list, show and edit do not display the existing assigned relationships - tried with @admin-bro/[email protected] as well.

@show981111
Copy link

show981111 commented Aug 6, 2021

same. did you solve the problem? In my case, I can see the logs from TypeOrm select all columns, and I checked that admin-bro gets all the instances from find() at Resource but it is just not mapped to the UI. Also, if I change the variable name as the column name in the Database, then it works correctly. For example, in my Database, there is TEACHER table and it has a column, FK_TEACHER_teacherID. In my TEACHER entity, I had a member variable teacherID which refers to the "FK_TEACHER_teacherID." At this time, foreign key does not show up in the list, but if I change the name to FK_TEACHER_teacherID, then it shows up.

    @Column({ name: 'FK_TEACHER_teacherID' })
    @RelationId((teacher: Teacher) => teacher.teacher)
    @ApiProperty()
    teacherID: string; // if I change teacherID -> FK_TEACHER_teacherID, it works

    @ManyToOne((type) => TeacherID, (TeacherID) => TeacherID.teacherID, {
        onDelete: 'CASCADE',
        onUpdate: 'CASCADE',
    })
    @JoinColumn({ name: 'FK_TEACHER_teacherID' })
    teacher: TeacherID;

@es-lynn
Copy link

es-lynn commented Oct 12, 2021

Same problem here. It does not appear in the UI.

EDIT: So @show981111's advice is correct. I had to change my variable name to be exactly the same as the column name. Previously the variable name was named teacherId while the database table was named teacher_id, and AdminBro was not able to pick up the relation. After renaming the database table to be teacherId, it was able to work.

@lolsborn
Copy link

I'm having this problem, renaming columns to use the FK names seems not ideal, especially since this example isn't explicitly naming the FKs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants