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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: Jsonb_apply: apply functions to Postgres JSON, like it's Lisp

3 点作者 fforflo8 个月前
Hi HN,<p>Here&#x27;s a small Postgres extension I’ve been working on: jsonb_apply.<p>This extension allows you to dynamically apply functions to jsonb objects, both recursively and with optional arguments.<p>The general signature looks like this:<p>select jsonb_apply(doc jsonb, func text[, variadic &quot;any&quot; args1_n])<p>You don&#x27;t have to specify types for the arguments, but they&#x27;ll be used in lieu of parser hints, to find the appropriate function to call.<p>So you can do things like this.<p>select jsonb_apply(&#x27;{ &quot;id&quot;: 1, &quot;name&quot;: &quot;John&quot;, &quot;messages&quot;: [ &quot;hello&quot; ] }&#x27;, &#x27;replace&#x27;, &#x27;hello&#x27;, &#x27;bye&#x27;);<p>{&quot;id&quot;: 1, &quot;name&quot;: &quot;John&quot;, &quot;messages&quot;: [&quot;bye&quot;]}<p>Came in handy for the couple of cases I wanted it for.<p>It&#x27;s mostly text-oriented for now, but I&#x27;m putting it out there, just in case anyone else wants something more LISPy in Postgres.

暂无评论

暂无评论