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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: Write universally accessible SQL, not library-specific ORM wrapper APIs

112 点作者 ckmar将近 4 年前

11 条评论

simonbarker87将近 4 年前
I feel like one of the few JS devs who is happy to just write SQL. Inline or as a stored procedure I just don’t see how learning an ORM and all it’s issues and bugs is harder than learning SQL.
评论 #28136012 未加载
评论 #28135791 未加载
评论 #28136591 未加载
评论 #28136548 未加载
评论 #28194511 未加载
评论 #28156052 未加载
cabalamat将近 4 年前
In the readme you say:<p>&gt;This contrasts against traditional (&quot;stateful&quot;) ORMs which use query builders (rather than raw SQL) to return database-aware (rather than pure) objects.<p>&gt;The name pureORM reflects both that it is pure ORM (there is no query builder dimension) as well as the purity of the mapped Objects.<p>I don&#x27;t know what you mean by &quot;pure&quot; or &quot;purity&quot; here, and i think an explantion would help.<p>Also, in the code:<p><pre><code> db.one(query) </code></pre> &quot;one&quot; does not strike me as a particularly expressive method name.
评论 #28131970 未加载
评论 #28131261 未加载
zzzeek将近 4 年前
SQLAlchemy author here.<p>I would just note that these two statements are contradictory:<p>&gt; The name pureORM reflects both that it is pure ORM (there is no query builder dimension)<p>and then<p>&gt; Specifying all the columns is tedious; lets use BaseBo.getSQLSelectClause() to get them for free.<p>the &quot;getSQLSelectClause()&quot; is absolutely a query builder function. Building out the columns to select from is in fact where things get very complicated if you are for example using SQL aliases, selecting the entity from subqueries, etc. I would predict this method would have to be very complicated to truly be useful in such real world scenarios, so you&#x27;d end up with a &quot;pure&quot; ORM that still has a significant query builder, just one that has its own particular brand of awkwardness in that the textual SQL you write has to match up with the assumptions of getSQLSelectClause().
评论 #28134835 未加载
评论 #28131980 未加载
评论 #28131798 未加载
ldd将近 4 年前
This may sound odd, but I never understood using heavy classes with relational databases.<p>I use javascript too, and at most I need a couple of HOF (higher order functions) to do most of the work I need.<p>Then again, I do use typescript and its type system, so maybe I am not the target audience.
评论 #28138915 未加载
gigatexal将近 4 年前
IMO ORMs are an abstraction too far. I’d rather use a query builder. It gives you better control over the query if you must use such an abstraction. Of course I would much prefer raw SQL and then doing the mapping to objects and serialization myself but that’s not for everyone and yadda yadda move fast … startups etc etc
ltbarcly3将近 4 年前
I tried to do something similar with <a href="https:&#x2F;&#x2F;github.com&#x2F;justinvanwinkle&#x2F;Norm" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;justinvanwinkle&#x2F;Norm</a> about 10 years ago. It hasn&#x27;t generated a lot of interest, but I find it quite useful to construct queries without having to learn the minutia of an ORM library, or even a SQL generation library.<p>Probably one of the best parts of Norm, and a big part of why I wrote it, is that it doesn&#x27;t require you to have a hardcoded copy of the databases schema in your code, it just works like SQL.<p>I put quite a bit of effort into making bulk inserts efficient, as well as making sure rows could be streamed from the database while buffering as few as possible in memory on the client.<p>I still maintain and update for my own use. Feel free to make suggestions or request features.
评论 #28135246 未加载
sparker72678将近 4 年前
I mean, more power to you if this is something you want, but writing raw SQL is something I will never miss.
评论 #28131159 未加载
评论 #28134796 未加载
评论 #28135111 未加载
cpursley将近 4 年前
I bounced when I saw the Class extends syntax.
评论 #28130920 未加载
hardwaresofton将近 4 年前
In this space but a little lighter:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;gajus&#x2F;slonik" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gajus&#x2F;slonik</a>
1MachineElf将近 4 年前
FYI, it&#x27;s only for PostgreSQL.
tomrod将近 4 年前
I mean, good luck when you are later porting to another DB system.
评论 #28130588 未加载
评论 #28130654 未加载
评论 #28130641 未加载
评论 #28130787 未加载
评论 #28130500 未加载
评论 #28131288 未加载