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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

How many lines of C++ does a minimal CRUD database application need?

2 点作者 greenrobot将近 5 年前
Check this example; two lines for initialization, one line for each operation:<p><pre><code> obx::Store store(create_obx_model()); obx::Box&lt;Task&gt; taskBox(store); obx_id id = box.put({.text = &quot;Buy milk&quot;}); &#x2F;&#x2F; Create std::unique_ptr&lt;Task&gt; task = box.get(id); &#x2F;&#x2F; Read if (task) { task-&gt;text += &quot; &amp; some bread&quot;; box.put(*task); &#x2F;&#x2F; Update ... box.remove(id); &#x2F;&#x2F; Delete } </code></pre> Can it be done shorter than that?<p>PS.: the example shows user code only, there&#x27;s a tool to generate boilerplate code, e.g. the Task struct and &quot;binding&quot; it to database.

2 条评论

_448将近 5 年前
Here is an example from Wt&#x27;s DBO tutorial: <a href="https:&#x2F;&#x2F;www.webtoolkit.eu&#x2F;wt&#x2F;doc&#x2F;tutorial&#x2F;dbo.html" rel="nofollow">https:&#x2F;&#x2F;www.webtoolkit.eu&#x2F;wt&#x2F;doc&#x2F;tutorial&#x2F;dbo.html</a>
tcbasche将近 5 年前
As many as is required?<p>This just looks like a competition ...