DEV Community

Adam Sung Min Park
Adam Sung Min Park

Posted on

UUID

Soo i was still kinda messing with my CRUD function i have made, and came up with this issue where my ID# for each entry could be the same if i were to delete the post in between the collection.
Since my way of generating not so unique ID was to get all the entries from the DB and count them up, and just add 1 to the total number.

with this approach, if i were to erase post #2, out of 5 entries, my 6th post which should have an id of 6 would have 5 instead.

In order to fix this issue, I decided to take a look at UUID.
At first I wasnt so sure how to use it since it was giving my error when i simply set {'id' : uuid.uuid4()}.
The thing is that I had to generate the ID first and give it to the key value pair.

and there goes my other problem of integer length being too long, and so on but I was able to make it work with what I think "cheap shots" but hey, as long as it works, i am happy.

Probably going to fix it once I get more use to using UUID.

TL;DR UUID works and i am happy nonetheless.

Top comments (0)