Thursday, 6 May 2021

Using literal in include (literal join) with sequelize

I have a problem implementing a join to stored procedure that return a table, The problem is: I have a stored procedure who returns me one uuid (and others fields), To apply as a filter to the real query I thought to use an Inner join, example:

SELECT
    ot.*
FROM
    "OriginalTable" as ot
INNER JOIN "MyStoredProcedures"(param1, params2) as enableds
    ON ot.uuid = enableds.uuid
...

Something like:

OriginalModel.findAll({
    include: [{
        model: sequelize.fn('MyStoredProcedures', param1, param2),
        required: true,
    }],
});

But I realized it isn't supported, getting:

TypeError: include.model.getTableName is not a function

There are some way to do an inner join with a literal like value?

Thanks, sorry my poor english



from Using literal in include (literal join) with sequelize

No comments:

Post a Comment