0

Models Price, Varient One ,Varient Two ,Item One Item have varient one and varient two , and many prices

They are my relations

db.tbl_itemPrice.belongsTo(db.tbl_varientOne,{foreignKey:'varientOne'})
db.tbl_itemPrice.belongsTo(db.tbl_varientTwo,{foreignKey:'varientTwo'})
db.tbl_item.hasMany(db.tbl_price,{foreignKey:'item'})

And then I want to join the table item , price, varient one and varient two . This is my controller-

exports.find = (req, res) => {
    Price.findAll ({
        include:[{
            model:VarientOne,VarientTwo

        }],

    }).then (item => {
        res.send(item)
    });
};

How can I join all above tables in sequelize

1 Answer 1

1

It is same as what you did.

include:[
    {model:A},
    {model:B},
    {model:C,include:[{model:C.1}]},
    {model:D,include:[{model:D.1,include:[{model:D.1.2}]}]},
]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.