Does sequelize support SQL Server views?

Issue

I’m working on a project that I need to define a model from SQL Server views. Is it possible to define a model from views according to not to use table joins and decrease complexities.

Solution

Yes, you can point a Sequelize model at a view, rather than a table at least for SELECT statements (e.g. model.findAll()) I doubt that model.sync() would work against a view, but haven’t tested. IIRC, some databases allow INSERT, UPDATE or DELETE against views in limited cases) and in those limited cases you might be able to use model.create(), model.update() or model.delete() also.

Answered By – KenOn10

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published