Relationships - Unable to display related data on Forest Admin Explorer

Description

Unable to display related data on Forest Admin Dashboard. Getting a message - There is no related data to explore. Kindly guide me on what am I missing and how to get my Dashboard display related data.

Feature(s) impacted

Explorer

I am trying to display related data for two tables Users and UserSubscriptions

Here is the code that I have added for creating relationships →

In /models/users.js

Users.hasOne(models.userSubscriptions, {
      foreignKey: {
        name: 'userIdKey',
        field: 'userId',
      },
      sourceKey: 'userId',
      as: 'userSubscription',
    });

In models/user-subscriptions.js

UserSubscriptions.associate = (models) => {
    UserSubscriptions.belongsTo(models.users, {
      foreignKey: {
        name: 'userIdKey',
        field: 'userId',
      },
      targetKey: 'userId',
      as: 'user',
    });
  };

One user can have only one subscription plan.

However, here is what I see in the explorer section for both the tables -

Also please note, I have not specified any keys on the actual table, is it required? Can we display related data without defining keys?

Observed behavior

Related data is not seen

Expected behavior

Related data should be seen.

Failure Logs

In this optional section, please:

  • include any relevant log snippets if necessary,
  • or remove this section if left empty.

Context

  • Project name: …
  • Team name: … Gerald
  • Environment name: …Dev
  • Agent type & version: …
  • Recent changes made on your end if any: …

Hi @Nam_B,

The explorer is just for exploring Has Many and not Has One / Belongs To

Thanks @vince I will try that out and will inform you back.

But of course you can access your has one / belongs to in the details view :wink:

@vince In that case, I am not seeing details from userSubscriptions in details view. I have added a hasOne and belongsTo relationship there. Any suggestions for that

Did you try to make sure your field is not hidden ?
Is your new relationship present in your .forestadmin-schema.json file ?

@vince Do you have any suggestion on how to overcome this error.
2022-03-01T22:07:43.597+05:30 e[31m[forest] :deciduous_tree::deciduous_tree::deciduous_tree: Unexpected error: operator does not exist: uuid = character varyinge[39m

2022-03-01T22:07:43.597+05:30 e[31m{e[39m

2022-03-01T22:07:43.597+05:30 e[31m “name”: “SequelizeDatabaseError”,e[39m

2022-03-01T22:07:43.597+05:30 e[31m “parent”: {e[39m

2022-03-01T22:07:43.597+05:30

Copy
e[31m “length”: 210,e[39m
e[31m “length”: 210,e[39m

2022-03-01T22:07:43.597+05:30 e[31m “name”: “error”,e[39m

2022-03-01T22:07:43.597+05:30 e[31m “severity”: “ERROR”,e[39m

2022-03-01T22:07:43.597+05:30 e[31m “code”: “42883”,e[39m

2022-03-01T22:07:43.597+05:30 e[31m “hint”: “No operator matches the given name and argument types. You might need to add explicit type casts.”,e[39m

2022-03-01T22:07:43.597+05:30 e[31m “position”: “292”,e[39m

2022-03-01T22:07:43.597+05:30 e[31m “file”: “parse_oper.c”,e[39m

2022-03-01T22:07:43.597+05:30 e[31m “line”: “731”,e[39m

2022-03-01T22:07:43.597+05:30 e[31m “routine”: “op_error”,e[39m

I think this error is preventing the dashboard from rendering while a row is selected.

Is it related to this topic :thinking: ? If not please create a new issue :wink:

@vince Yes, the column types are different on which the relationship is created. It thus leads to an error and in turn, the Dashboard doesn’t display any related information. So it is indirectly related.

@vince I created another topic as suggested.
Topic created for type mismatch.