dwyl / phoenix-ecto-append-only-log-example

📝 A step-by-step example/tutorial showing how to build a Phoenix (Elixir) App where all data is immutable (append only). Precursor to Blockchain, IPFS or Solid!
GNU General Public License v2.0
78 stars 7 forks source link

Questions/thoughts on ALOG style functions using CID #23

Open RobStallion opened 5 years ago

RobStallion commented 5 years ago

relates to #22

Insert

From what I can tell insert would remain largely unchanged. We would just swap inserting the UUID for a CID we make.

Please add thoughts on this if I have overlooked anything

Get

How do we want to handle someone calling get with an old/previous CID?

Do we want to...

Update

How do we want to handle someone calling the update function with an old/previous CID?




inserted cid(PK)1 name address prev
1541609554 gVSTedHFGBetxy Bruce Wane 1007 Mountain Drive, Gotham null
1541618643 smnELuCmEaX42 Bruce Wane Rua Goncalo Afonso, Vila Madalena, Sao Paulo, 05436-100, Brazil gVSTedHFGBetxy
nelsonic commented 5 years ago

@RobStallion thank you for opening this issue/question and sharing your thoughts! 😍

Understanding why we need to make the alog API changes requires insight into where we are going with our product development. Our Product is an "Activity Tracking" App which has the deliberately/deceptively simplistic name of "Time". ⏳

I plan on making a dent into clarifying this in the https://github.com/dwyl/product-roadmap over the weekend (family commitments 👫 and other demands 🏡 on my time permitting ...) 🔜

nelsonic commented 5 years ago

Content with Persistent entry_id for Ease of Querying

In order to make a record "queryable" it needs to have an "ID" that is consistent across rows/versions. In this case we would use an entry_id which corresponds to a few characters of the cid. Our Ecto adapter or query would need to be "smart" about this. It would need to "check" if that entry_id already exists in the database. If for example entry_id gV already exists in the database we would use the next character of the original cid e.g: gVS and so on until an unused entry_id is found.

inserted cid(PK)1 name address prev entry_id
1541609554 gVSTedHFGBetxy Bruce Wane 1007 Mountain Drive, Gotham null gV
1541618643 smnELuCmEaX42 Bruce Wane Rua Goncalo Afonso, Vila Madalena, Sao Paulo, 05436-100, Brazil gVSTedHFGBetxy gV
1541667890 alkjsnssuwnd123 Bruce Wane 10 Downing Street smnELuCmEaX42 gV
1541098765 poiuyerfghnt345 Bruce Wane 10 Downing Street alkjsnssuwnd123 bruce

Redirect Table:

If a user decides they want to have a human-friendly entry_id e.g: "bruce" instead of gV, then we would need to have a entry_id_redirect table:

inserted old_entry_id current_entry_id
1541098765 gV bruce

such that visiting: myaddressbook.com/gv should redirect to myaddressbook.com/bruce

@RobStallion does this clarify how content can be queried? If not, please ask further clarifying questions. thanks!