How to make belongsTo editable in relationship?

Observed behavior

image

I tried to create new record via relationships

GET /forest/products/${id}/relationships/bundleComponents

but belongsTo field is not editable. I already disable read only mode but the result still same. Is there a way to make this field editable when create new record especially the component field?

Expected behavior

can edit belongsTo field when create new record via relationships

Code

Products.associate = (models) => {
    Products.hasMany(models.productComponents, {
      foreignKey: {
        name: 'productIdKey',
        field: 'product_id',
      },
      as: 'bundleComponents',
    });
}
ProductComponents.associate = (models) => {
  ProductComponents.belongsTo(models.products, {
    foreignKey: {
      name: 'productIdKey',
      field: 'product_id',
    },
    as: 'product',
  });
  ProductComponents.belongsTo(models.products, {
    foreignKey: {
      name: 'componentProductIdKey',
      field: 'component_product_id',
    },
    as: 'component',
  });
};

Thank you so much in advance.

  • Project name: Siklus
  • Team name: Operations
  • Environment name: Staging
  • Agent (forest package) name & version: forest-express-sequelize@8.5.14
  • Database type: postgresql
  • Recent changes made on your end if any: -

Hey @umar006,

I just realised it’s an issue on our side.
The issue is that we autocomplete the inverse relationships and disable the field to avoid mistakes. But in your case you have Product bundle name which is the actual inverse relationships and Component which both references the Product collection, and we consider wrongly that both are the inverse relationships :sweat_smile:
Am I correct ?

I will create a bug ticket, sorry about that

1 Like

Hello @vince

can you give an estimated time when this bug is fixed?

thank you in advance,

Hey @umar006,

I’m working on it at the moment. I’ll let you know as soon as it is fixed and released :wink:
Sorry for the delay

I retried the bug but I could not reproduce on your version. I tested with a too old versions. This was fixed in forest-express-sequelize@8.0.6 :thinking:
Could you share a video reproducing your error ?
And do you have any error in your console when that happens ?

sure, this how to reproduce the error and no error log in my console

Okey I finally found the issue :sweat_smile:
I’ll let you know once it is released :wink:

Glad to hear that you finally found the issue, and I appreciate your efforts in resolving it.

Hey @umar006,

The fix should be live. Let me know if it works for you :smile:

1 Like

Awesome! Thanks for the update! I just tested it, and it’s working as expected. Keep up the great work! :smile: