support subquery expressions
lagleki opened this issue · 2 comments
lagleki commented
exists is probably the most common
Superficially looks like a function. Any hints on crossdialect syntax?
planetarydev commented
Have a look at the from clause helper which already supports subqueries.
https://github.com/planetarydev/json-sql-builder2/tree/master/sql/helpers/queries/from
function() {
return sql.build({
$select: {
$from: {
people: 'p',
skills: {
$select: { $from: 'people_skills' }
}
}
}
});
}
// SQL output
SELECT
*
FROM
people AS p,
(
SELECT
*
FROM
people_skills
) AS skills
// Values
{}We only need to write an exists - helper
planetarydev commented
It is done by the select operator...
https://github.com/planetarydev/json-sql-builder2/blob/master/sql/operators/select/select.js#L82