Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sequilize join two tables and find

 table_with_foreign_key.belongsTo(table_linked,{
        foreignKey: 'id_row_from_table_with_foreign_key',
        as: 'linked'
    })

    let res = await table_with_foreign_key.findAll({
        where:{
            '$linked.id$': 1
        },
        include: {
            model: table_linked,
            as: 'linked',
        }
    });
 
PREVIOUS NEXT
Tagged: #sequilize #join #tables #find
ADD COMMENT
Topic
Name
7+1 =