Help to belongsToMany relationship - SEQUELIZE

8 views
Skip to first unread message

Eric Alves da Rocha

unread,
Apr 20, 2016, 4:18:54 PM4/20/16
to nod...@googlegroups.com
Hi folks.

Primarily, sorry my bad english. rsrsrs

I have a little problem. This works well:

models.AgileBoardColumnModel.belongsToMany(models.TaskModel, { as: 'tasks', through: 'agile_board_columns_tasks', foreignKey: 'column_id' });
models.TaskModel.belongsToMany(models.AgileBoardColumnModel, { as: 'tasks', through: 'agile_board_columns_tasks', foreignKey: 'task_id' });

JSON findAll()
​ return​
:

[
  {
    "id": 20,
    "name": "Pendentes",
    "tasks": [
      {
        "id": 7,
        "description": "Coluna 1",
        "agile_board_columns_tasks": { (<---- Here i want the name to be"column")
          "order": 1,
          "task_id": 7,
          "column_id": 20
        }
      }
    ]
  }
]


thanks!

Att.,
Eric A. da Rocha
Reply all
Reply to author
Forward
0 new messages