Live data from Hacker News

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

news.ycombinator.com

1–3 of 3 posts

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

#1
Check this example; two lines for initialization, one line for each operation:

    obx::Store store(create_obx_model()); 
    obx::Box taskBox(store);
 
    obx_id id = box.put({.text = "Buy milk"});  // Create
    std::unique_ptr task = box.get(id);   // Read
    if (task) {    
        task->text += " & some bread";
        box.put(*task);                         // Update
        ...
        box.remove(id);                         // Delete
    }
Can it be done shorter than that?

PS.: the example shows user code only, there's a tool to generate boilerplate code, e.g. the Task struct and "binding" it to database.