Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It is sometimes convenient, when using a .join() in a .query(), to pr…
…oject the output as something different than the .from() table. For example, if you have new joli.query().select('table2.*').from('table1').join('table2', 'id', 'table2.id') This will be translated to: select table2.* from table1 left outer join on table1.id = table2.id You may want to prepare the SQL statement in this backwards order (table1 left outer joined to table2) for performance reasons. However, you may need the results projected as 'table2' items. To aid in this, I've added a simple .as() function. You can use .as() to change a query to project as a different table than the .from() function: new joli.query().select('table2.*').from('table1').join('table2', 'id', 'table2.id').as('table2') These will produce results as 'table2' objects.
- Loading branch information