TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Writing Composable SQL Using Knex and Pipelines

58 点作者 tie-in6 个月前

9 条评论

larodi6 个月前
I really fail to understand why &quot;writing HTML mixed with JS&quot; is okay for React, and mixing regex with what-not is okay for...like...everyone, but it would not be okay for so many ORM people to actually have properly bound SQL in-place. Really boggles me down.<p>Besides - I&#x27;ve seen one of the best possible schema-on-the-fly-on-top-of-RDBMS systems that can ever exist, is in production, and even there it is much better every so often to fallback to either the Virtual SQL layer or to hardcore SQL when performance is needed. In all other occasions - well okay, but unless you actually have a proper MOP (meta-object-protocol or entity&#x2F;relationship schema, name it what you like) in-place&#x2F;available, the DB schema becomes the MOP and you are back to square one...
评论 #42267344 未加载
评论 #42268382 未加载
评论 #42267564 未加载
bearjaws6 个月前
Used knex before typescript was a thing, it was such a life saver.<p>Everytime an ORM conversation would come up, I would bat it down, especially at the time where Bookshelf (now 100% dead) and Sails.js were popular.<p>We were all in on knex and it was such a life saver, especially migrations.<p>The only custom thing we did was an extension that would run explain on queries and flag anything that had a query cost over some value (I forget what it was).<p>Made finding new queries that were unperformant really easy.<p>The composability was nice, but we didn&#x27;t need to use it all that much. It made one of our services that was essentially a query builder very easy to build. Something like &quot;Find me patients that need X work Y weeks from now, now add a filter for medication type...&quot; was easy to script out.
评论 #42266485 未加载
评论 #42267272 未加载
anonzzzies6 个月前
We use Knex a lot because it can be used dynamically. All newer systems are based on typescript, which is great, but not dynamic unless you do code gen. And that&#x27;s quite a lot slower because of the compilation steps in our experience. With Knex we can have users building a massive query dynamically while seeing intermediate results immediately.
maciejgryka6 个月前
I’d encourage everyone, who finds this appealing to check out how Ecto works in Elixir. It’s all functional &amp; immutable goodies and pipelines are built into the language and idiomatic.<p>Definitely looks weird at first glance (and Ecto is kinda weird even if you’re familiar with Elixir), but it’s such a joy to use once you grok it.
mythz6 个月前
I&#x27;ve also just released a type safe, SQL-like parameterized TypeScript&#x2F;JS ORM for SQLite, MySQL and PostgreSQL. I wrote it because I couldn&#x27;t find any other ORMs with type-safe query builders where joined tables and column references are type checked against my data models to enable design-time type checking and safe refactoring.<p>It&#x27;s also highly composable as SQL expressions can be embedded within SQL Builders which can themselves be embedded within other Query Builders.<p><a href="https:&#x2F;&#x2F;litdb.dev" rel="nofollow">https:&#x2F;&#x2F;litdb.dev</a>
评论 #42267328 未加载
poxrud6 个月前
I&#x27;ve used Knex, ActiveRecord and many other ORM&#x27;s and query builders. At some point, beyond basic queries you start wasting time coming up with SQL statements and then having to convert them to your ORM&#x2F;builder&#x27;s syntax. I&#x27;ve reached the point now where it&#x27;s just easier to stick with writing SQL and having a library that removes the possibility of sql injections. My current stack is postgres.js and dbmate for migrations.
评论 #42267779 未加载
评论 #42267758 未加载
h1fra6 个月前
Unrelated but started using Kysely after struggling too much with knex and prisma, that&#x27;s a breath of fresh air. Excellent native typing, good tooling, and no missing features.
fbn796 个月前
I like knex, but would love it more if all methods does not mutates the original data structure. A pure version of knex would be great
natpalmer17766 个月前
Here I was wondering how you managed to use K’nex (toy) to write code lol
评论 #42266857 未加载
评论 #42267003 未加载