sequelize.js - How to have a self-referencing many-to-many association in Sequelize? -


i have model called task, can have many parent tasks (multiple ancestors) and/or child tasks.

if model without sequelize, i'd have table called parenttasks, have parenttaskid , taskid determine relationship , tasks table id primary key.

using sequelize, possible? i've tried many different permutations , combinations, none lead want.

any appreciated.

thanks.

what have tried?

how this:

var task = sequelize.define('task', {   name: sequelize.string });  task.hasmany(task, { as: 'children', foreignkey: 'parenttaskid', through: 'parenttasks' }); task.hasmany(task, { as: 'parents', foreignkey: 'taskid', through: 'parenttasks' }); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -