工具与资源github.com
PostgREST——从任意 PostgreSQL 数据库生成 REST API
PostgREST – REST API from any PostgreSQL database
2015 — 2017,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
PostgREST 是一个开源工具,可以把任意 PostgreSQL 数据库自动转换成一个符合规范的 RESTful API,无需编写后端代码。它深度利用 Postgres 自身的能力来做鉴权、缓存和分页,是“数据库即 API”思路的代表项目。
为什么经久不衰:它挑战了“必须手写后端 CRUD 层”的常规做法,多年后仍是低代码/直连数据库 API 思路的标杆,对理解 Postgres 能力边界和 API 设计权衡很有启发。
HN 评论精选
亮点在于与 Postgres 深度集成,虽非未来方向但有很多实用设计
与许多“把关系型数据库暴露为 API”的方案不同,这个项目的有趣之处在于它与 Postgres 的深度结合:它直接用 Postgres 用户做授权,还依赖 Postgres 的统计收集器来生成缓存头。我也很喜欢用 Range 头做分页的想法(本应是业界惯例却很少见)。我不认为这是 Web 开发的未来,但它提供了不少非常实用的点子,令人耳目一新。即使你完全不感兴趣,也值得花 12 分钟看看它的介绍演讲。
pilif查看英文原文
Contrary to many other "expose a RDBMS schema as an API" solutions, this one is interesting due to its very close tie-in with postgres. It even uses postgres users for authorization and it relies on the postgres stats collector for caching headers. I also very much liked the idea of using `Range` headers for pagination (which should be out-of-band but rarely is). I'm not convinced that this is the future of web development, but it's a nice refreshing view that contains a few very practical ideas. Even if you don't care about this at all, spend the 12 minutes to watch the introductory presentation.
批评 Web 开发者忽视数据库能力,重复造轮子
这是很好的工作。为什么 Web 圈的人不用存储过程和约束,对我来说是个谜。那些 Web 框架的发明者大概只读了数据库手册的前两章,于是写了一大堆代码,逼你在别处用另一种语言补上语义。PostgreSQL 是先进的技术:可扩展 SQL、自定义类型、多种语言的 PL/SQL、后台任务、触发器、约束、权限。至于“不想被数据库锁定”的论调,实在缺乏常识——你宁愿把自己锁进不可预测的 Web 框架洪流,也要躲避一个有 20 年历史、建立在坚实理论基础上的数据库产品。
benkant查看英文原文
This is good work and if I ever did web development, it would be like this. Why people in the web world don't use stored procedures and constraints is a mystery to me. That this approach is seen as novel is in itself fascinating. It's like all those web framework inventors didn't read past chapter 2 of their database manuals. So they wrote a whole pile of code that forces you to add semantics in another language elsewhere in your code in a language that makes impedance stark. PostgreSQL is advanced technology. Whatever you might consider doing in your CRUD software, PostgreSQL has a neat solution. You can extend SQL, add new types, use PL/SQL in a bunch of different languages, background workers, triggers, constraints, permissions. Obviously there are limits but you don't reinvent web servers because Apache doesn't transcode video on the fly. Well, you do if you're whoever makes Rubby on Rails. The argument that you don't want to write any code that locks you to a database is some stunning lack of awareness, as you decide to lock yourself into the tsunami of unpredictability that is web frameworks to ward off the evil of being locked into a 20 year database product built on some pretty sound theoretical foundations. Web developers really took the whole "let's make more work for ourselves" idea and ran with it all the way to the bank. You'd have to pay me a million dollars a year to do web development.
质疑 HTTP 开销和复杂业务逻辑下的可扩展性
恕我直言,为什么要通过 HTTP 去查询数据?为什么不直接连数据库而要承受 HTTP 的开销?更干净、更符合标准值得付出这些开销吗?还有,当需要应用需要扩展的复杂业务规则时怎么办?对这种做法我有很多疑问……
jister查看英文原文
I'm sorry but why would I go through HTTP to query data? Why can't I just hit the database directly without the overhead of HTTP? Does a cleaner and being more standards-compliant worth the overhead of passing through HTTP? And what happens when you start applying complex business rules that needs to scale? So many questions about this approach...
警告:外部 API 不应直接绑定数据库模型,schema 版本化方案很糟糕
一般来说,不要把外部 API 绑定到你的数据模型上,除非你能承诺永不改动(提示:你做不到)。另外它的版本管理是整个 API 层面的版本管理,靠为每个版本建不同的数据库 schema 实现,这是个糟糕的主意,我不推荐使用。
dyadic查看英文原文
It's interesting that it can handle versioning, and could be something to look into. But generally, DO NOT tie your external APIs to your data model unless you can can commit to never changing them. (hint: you can't). --- Edit: The versioning is whole API versioning instead of resource versioning and works by using a different db schema for each version. This is a terrible idea and I wouldn't recommend using this at all
历次讨论
同类还值得读
直接在浏览器中启动 Linux 内核
Boot a linux kernel right inside your browser.
Fabrice Bellard 的 JSLinux 页面,用 JavaScript 在浏览器里启动一个 Linux 内核,并提供一个可交互的终端环境。
工具与资源上首页 5 次 · 2011–2025bellard.orgHacker News 未公开功能与行为清单(2018)
A List of Hacker News's Undocumented Features and Behaviors (2018)
数据科学家 Max Woolf 整理的 Hacker News 未公开功能与行为清单,涵盖投票机制、排名算法、账号惩罚等社区运作细节。
工具与资源上首页 5 次 · 2019–2025github.comMapSCII:在终端中用盲文和 ASCII 渲染地图
MapSCII – Braille and ASCII map renderer for the console
MapSCII 是一个在命令行终端里渲染地图的开源工具,用盲文字符和 ASCII 字符把地理数据画成可交互浏览的字符地图。
工具与资源上首页 5 次 · 2017–2025github.com顶尖大学的免费在线课程
Free Online Courses from Top Universities
Open Culture 整理的一份免费在线课程合集,汇集了全球顶尖大学(如 MIT、斯坦福、耶鲁等)向公众开放的网络课程资源,涵盖音频、视频等多种形式。
工具与资源上首页 5 次 · 2010–2022openculture.com淘气字符串:容易引发用户输入问题的字符串清单
Naughty Strings: A list of strings likely to cause issues as user-input data
一个 GitHub 仓库,收录了大量容易让程序出问题的用户输入字符串,如特殊字符、emoji、SQL 注入片段、系统命令等,供开发者用于测试输入处理逻辑。
工具与资源上首页 4 次 · 2015–2020github.com