I am creating an application that should be able to have ‘infinitely’ nested lines.
I would like to be able to store their location in the database and have it displayed correctly on the UI.
For example if I have ‘Record A’ with the following arbitrarily named lines:
Position 1 – A
Position 1.1 – AB
Position 1.1.1 – ABC
Position 2 – D
Position 2.1 – DE
Position 3 – F
Position 3.1 – FG
Position 3.2 – FH
Position 3.3 – FI
Position 3.3.1 – FIJ
Position 3.3.2 – FIK
Say I want to move line FIK to anywhere else on the record in a different order
Position 1 – FIK
Position 2 – A
Position 2.1 – AB
Position 2.1.1 – ABC
Position 3 – D
Position 3.1 – DE
Position 4 – F
Position 4.1 – FG
Position 4.2 – FH
Position 4.3 – FI
Position 4.3.1 – FIJ
Right now my backend line schema looks like this (there are more fields but this is for simplicity’s sake:
Line ID – Number
Child Of – Line ID or null (Not functional, this is the point of my post)
Position – Number (I don’t have X.X.X numbering system implemented, right now it is just integer numbers that are used with sort() to make sure the lines are in order)
How would I handle this?
I am using clean architecture with Domain, Infrastructure (IRepository), Application (Repository and UseCases), and Presentation layers.
What would I need to track on the UI and what kind of logic/functions would I want in my Application layer to handle this type of logic?
Please let me know if you need more details, I would be happy to supply them.
Currently using React Native / a NoSQL database but I don’t really care about the actual code, a pseudocode answer with the high-level explanation would be amazing.
Thanks in advance!