balderdashy/sails-mysql — pull request #36 by bruce808 (2013-09-08 16:59:48+00:00)
Title: Added raw option to include raw criteria into SELECT statement

This change is a quick and dirty workaround to allow the Sails MySQL adapter to allow the use of subqueries and other advanced options that are not currently supported. The usage is shown below. Basically anything that is included with a key of "raw" will be inserted unchanged into the generated SQL statement. Note that the example is using the fibrous/node-fibers syntax.

Select all of the Fans that are linked to a given Organization by the OrgFans mapping table:

var criteria = { raw: "id IN (SELECT fanId FROM OrgFans WHERE organizationId = " + org.id + ")" };
var fans = Fans.future.find(criteria).wait();