0
Sequelizeで同じテーブルから2回選択する方法は?最後に、私は答えを見つけた同じテーブルからMySQL selectを続ける(左の結合)
select b.*, a.parent_id
from theSameTable as b left join theSameTable as a on b.parent_id = a.id
はここに私のMySQLのテーブルここ
私Sequelizeコード
const db = await ec.sequelize.define(tableDb, {
id: {
type: ec.Sequelize.INTEGER.UNSIGNED,
primaryKey: true,
autoIncrement: true
},
url: ec.Sequelize.STRING(511),
url_hash: ec.Sequelize.STRING(32),
name: ec.Sequelize.STRING(511),
full_name: ec.Sequelize.STRING(511),
parent_id: ec.Sequelize.INTEGER(11).UNSIGNED,
cnt: ec.Sequelize.STRING(255),
chk: ec.Sequelize.INTEGER(1)
}, {
indexes: [{
unique: true,
fields: ['url_hash']
}]
});
await ec.sequelize.sync();
そして、何あなたは自己結合sequelizeで約グーグルで見つけた後 ? – philipxy
[関連するレコードを含めて、Sequelizeで自己結合を照会する]の可能な複製(https://stackoverflow.com/questions/40294776/query-self-join-with-sequelize-including-related-record) – philipxy