TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

2 pointsby greenrobotalmost 5 years ago
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 comments

_448almost 5 years ago
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>
tcbaschealmost 5 years ago
As many as is required?<p>This just looks like a competition ...