View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page

.query()

.query() is only available on Sails/Waterline models using a SQL database (PostgreSQL and mySQL) adapter. Its purpose is to perform raw SQL queries.

Example

Pet.query('SELECT pet.name FROM pet', function(err, results) {
  if (err) return res.serverError(err);
  return res.ok(results.rows);
});

Notes

This method only works with PostgreSQL and mySQL! use .native() for Mongo.

This method does not return a promise. Refer here to promisify .query().

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Reference

We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book