adminjs icon indicating copy to clipboard operation
adminjs copied to clipboard

Not getting other columns value using foreign key from table

Open RudrikaJnext opened this issue 5 years ago • 2 comments

I have two tables one is Users and the second is Products,

Table: Users -> Column: id, userName, password, firstName

&

Table: Products -> Column: id, productName, userId

I have assign foreign key to get Users(id) -> userId

But I want the userName instead of userId in the Products table.

Is it possible to do in admin-bro? or is there any way to add mannual query for it?

RudrikaJnext avatar Apr 12 '21 11:04 RudrikaJnext

In your Users resource add isTitle: true to userName property, i. e.

const UserResource = {
  resource: User,
  options: {
    ...,
    properties: {
      userName: { isTitle: true },
    },
  },
};

dziraf avatar Apr 12 '21 11:04 dziraf

@dziraf Thank you for the solution! It works perfectly!

RudrikaJnext avatar Apr 12 '21 12:04 RudrikaJnext