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

2 points by greenrobot ↗ HN
Check this example; two lines for initialization, one line for each operation:

    obx::Store store(create_obx_model()); 
    obx::Box<Task> taskBox(store);
 
    obx_id id = box.put({.text = "Buy milk"});  // Create
    std::unique_ptr<Task> 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.

2 comments

[ 3.1 ms ] story [ 17.3 ms ] thread
As many as is required?

This just looks like a competition ...