What are people using as GUID?

Hello everyone!

I recently started learning Elixir and Phoenix and would really like to use non-sequential identifiers in the model layer.

I did a POC using the Uniq library (uuidv7) and I also know that Ecto itself provides an implementation of UUID v4.

The thing is that I would like to use something more URL-friendly, like cuid2, for example.

Do you have any library recommendations in this regard?

1 Like

If the requirement is an identifier that is easy to use in a URL then Uniq has a :slug format:

iex> Uniq.UUID.uuid7(:slug)
"AZMjUMHKdBiQVHVom_IcFA"
5 Likes

I guess the important point here is that you want to separate formatting needs from needs around the data creation. You can decide both of those individually. Just because the default formatting of uuids doesn’t work for you doesn’t mean you need to switch away from uuids.

3 Likes