V
V
Valeriu2017-11-05 16:28:43
MySQL
Valeriu, 2017-11-05 16:28:43

Why are table relationships not working [FeathersJS -sequelize]?

Hello,
there is:

  • framework Feathers ^2.2.3
  • ORM sequelize (feathers-sequelize ^2.3.2)
  • MySQL database
  • 2 tables between which you need to organize a relationship

in the category.model.js file I describe the relationship:
category.associate = function (models) {
    models.category.belongsTo(models.category_translate, {
      foreignKey: 'id',
      constraints: false,
      targetKey: 'category_id',
      as: 'translate'
    });
};

Now, if you access the address localhost:3030/category, then the result of this request is displayed:
SELECT `id`, `icon`, `parent` FROM `category` AS `category` LIMIT 10;

Tried like this localhost:3030/category?$select[]=translate to access fields from related table but got error.
What am I doing wrong?
How to access data from another table by link from the current model?
UPDATE:
Join the FeathersJS Telegram community https://t.me/featherjs

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question