you can write your own table-valued, aggregate and window functions when you use better-sqlite3 (see https://github.com/JoshuaWise/better-sqlite3/blob/master/doc...; see Database#function(), Database#aggregate(), Database#table()) in JavaScript.
But this is worth considering as an option.