QuazarOmega, 1 year ago (edited 1 year ago) Me trying to remember on whose output data having, count, sum, etc. work Once you know functions you would have no reason to go back. I propose we make SQL into this: <span style="color:#323232;">const MAX_AMOUNT = 42, MIN_BATCHES = 2 </span><span style="color:#323232;"> </span><span style="color:#323232;">database </span><span style="color:#323232;"> .from(table) </span><span style="color:#323232;"> .where( </span><span style="color:#323232;"> (amount) => amount < MAX_AMOUNT, </span><span style="color:#323232;"> table.field3 </span><span style="color:#323232;"> ) </span><span style="color:#323232;"> .select(table.field1, table.field3) </span><span style="color:#323232;"> .group_by(table.field1) </span><span style="color:#323232;"> .having( </span><span style="color:#323232;"> (id) => count(id) >MIN_BATCHES </span><span style="color:#323232;"> table.field0 </span><span style="color:#323232;"> ) </span> (Sorry for any glaring mistakes, I’m too lazy right now to know what I’m doing) …and I bet I just reinvented the wheel, maybe some JavaScript ORM?
Me trying to remember on whose output data having, count, sum, etc. work
having
count
sum
Once you know functions you would have no reason to go back. I propose we make SQL into this:
<span style="color:#323232;">const MAX_AMOUNT = 42, MIN_BATCHES = 2 </span><span style="color:#323232;"> </span><span style="color:#323232;">database </span><span style="color:#323232;"> .from(table) </span><span style="color:#323232;"> .where( </span><span style="color:#323232;"> (amount) => amount < MAX_AMOUNT, </span><span style="color:#323232;"> table.field3 </span><span style="color:#323232;"> ) </span><span style="color:#323232;"> .select(table.field1, table.field3) </span><span style="color:#323232;"> .group_by(table.field1) </span><span style="color:#323232;"> .having( </span><span style="color:#323232;"> (id) => count(id) >MIN_BATCHES </span><span style="color:#323232;"> table.field0 </span><span style="color:#323232;"> ) </span>
(Sorry for any glaring mistakes, I’m too lazy right now to know what I’m doing)
…and I bet I just reinvented the wheel, maybe some JavaScript ORM?