Reputation: 28611
I'm looking for a way to run custom query using Waterline in Sails.js.
For example I want to create a view, e.g.: CREATE VIEW ...
it doesn't make sense to run it via some model, like User.query()
.
Is there a way to run native query without referencing some specific model?
Upvotes: 2
Views: 771
Reputation: 24948
Waterline doesn't provide direct access to the underlying adapters; you have to go through a model. If it really bothers you philosophically to run a generic query through a specific model, you can always install and use the database driver directly (e.g. npm install pg
or npm install node-mysql
). But there are advantages to going through a model. For one thing, Waterline handles all the connection overhead for you. And if you change the connection for the model, then the generic query will automatically be using the new connection without you having to hunt it down and switch it yourself.
Upvotes: 3