Relations not visible

Hi,

Feature(s) impacted

Relations

Observed behavior

I have 3 SQL Tables

  • transactionBank
  • transactionCalculateTemplate
  • a table for transactionCalculateTemplate hasMany transactionBank

I didn’t see the transactionBank (There are no transaction bank …) when i’m in the view transactionCalculateTemplate even if the relations is set like this

 TransactionCalculateTemplate.belongsToMany(models.transactionBank, {
      through: 'transactionCalculateTemplateTransactionBank',
      foreignKey: 'transaction_calculate_template_id',
      otherKey: 'transaction_bank_id',
      as: 'transactionCalculateTemplateThroughTransactionCalculateTemplateTransactionBanks',
    });

Expected behavior

I need to see transaction bank associated to my transaction calculate template

Context

  • Project name: cashtrack
  • Team name: cashtrack
  • Environment name: all
  • Agent (forest package) name & version: forest-express-sequelize
    7.12.2 (using express 4.17.1)
  • Database type: PostgreSQL
  • Recent changes made on your end if any: …

Hello @michaelbaron,

You are trying to define a many-to-many relationship, am I correct?

For this purpose, you’ve created a joint table transactionCalculateTemplateTransactionBank?

Did you define the reverse relation in Sequelize? Because you need to define both relations way so they can be visible in Forest Admin.

TransactionBank.belongsToMany(models.transactionCalculateTemplate

As a complement, the belongsToMany / hasMany relationships are visible under the Related data section of a record.

You can found more information in the documentation for forest-express-sequelize relationships defintion in here.

Kind regards,
Morgan