Friday, 2 June 2017

Sequelize perform a raw query

I am trying to perfom a raw query on my model, but i don't get any result for it, when i point to a specific route on my server i want my model to perfom a raw query because the query is more complicated and i don't want to do it with ORM.

this is what i am doing:

  allPictures: function (req, res) {
        Foto.query("SELECT * FROM public.'Fotos' LEFT JOIN public.'Users' ON public.'Users'.id = public.'Fotos'.'userId';", { type: sequelize.QueryTypes.SELECT })
            .then(function(users){
                console.log("ENTERED");
            })

as i saw in the docs, the Foto.query, is sequelize.query, i don't understand very well how can i do this, any help?

Thanks



via Filipe Costa

No comments:

Post a Comment