2 ms·
You should be able to easily reconstruct the parent/child relationships from the OP's order/indent encoding scheme though (at least if you ensured that only "va
by xg15 3y ago
You should be able to easily reconstruct the parent/child relationships from the OP's order/indent encoding scheme though (at least if you ensured that only "valid" indents are stored, no child without a parent, etc)
So I think the easiest way would be to store as order/indent first and later migrate to parent/child when you implement features that need it.
The only change I'd do is to define "indent" more abstractly as the item's depth in the tree and not literally the number of spaces you want to render. That makes it a lot easier to spot invalid data, makes later migration easier - and also gives you more UI flexibility, because it allows you to change the rendering method or make it configurable per user (nested <ul>'s/<ol>'s, tabs, 8 spaces, 4 spaces, 1 space, etc)