# .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

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



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





<docmeta name="uniqueID" value="query546204">
<docmeta name="methodType" value="mcm">
<docmeta name="importance" value="undefined">
<docmeta name="displayName" value=".query()">


# .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

```js
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.





<docmeta name="uniqueID" value="query546204">
<docmeta name="methodType" value="mcm">
<docmeta name="importance" value="undefined">
<docmeta name="displayName" value=".query()">


Return response in format consistant with .find()
Return response in format consistant with .find()

`return res.ok(results); `
sends back JSON with info about the query and requires different handling than the default responses of the blueprint methods like 
`.find().  `
changing to results.rows produces consistent output.