Monday, 13 August 2018
Sequelize associations
I'm in the process of setting up a sequelize project on Postgres (though it could change to MySQL at some point, but don't worry about that too much for the moment) and I'm having a little trouble with the associations. I'm using feathers and feathers-sequelize to build my models, services, etc.I have 4 'primary' tables; - Employee - Client - Project - TaskA client can have many projects, a project can have many tasks, and a task can belong to many employees. Likewise, an employee can have many tasks, a task only belongs to one project, and a project belongs to 1 client.I then have an 'interim' table called employee_task, which should have foreign keys on employee.employee_id and task.task_id. It's primary key is simply [employee_id]:[task_id] and this tables purpose is to list all employee-task combos.All primary keys are GUID's except the employee_task table which is a string.I managed to get most of the associations setup but when it came to the employee_task table, I couldn't get any association working. Either all of the results would be returned even when passing ?employee_id=
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment