• QuazarOmega@lemy.lol
    link
    fedilink
    arrow-up
    0
    ·
    6 months 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:

    const MAX_AMOUNT = 42
    
    database
        .from(table)
        .where(
            (amount) => amount < MAX_AMOUNT,
            table.field3
        )
        .select(table.field1, table.field3)
        .having(
            (id) => count(id)
            table.field0
        )
    

    …and I bet I just reinvented the wheel, maybe some JavaScript ORM?