JasterV

JasterV

Any other libraries to create UUIDv4 beside Ecto?

So I don’t depend on Ecto but I need a well maintained library to generate unique identifiers.

The only library other than ecto seems to be “elixir-uuid”, but it hasnt been updated in ages and when I use it I get many warnings because of deprecated stuff. I’ve checked the issues on Github and some of them even state that the generated UUIDs can sometimes be duplicated…

So the only other option I see is using Ecto.UUID… but I don’t want to import this huge library only to use the UUID functionality

Any ideas here?

Most Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

My guess is that:

  1. Most projects already have ecto. Even if you aren’t using a database, its changesets, embedded schemas, and validators are useful.
  2. The rest just copy in the ~50 lines of code from here ecto/lib/ecto/uuid.ex at v3.11.2 · elixir-ecto/ecto · GitHub

Someone certainly could extract that to a library but it’s also just not that many lines of code, and they aren’t gonna change.

Marcus

Marcus

I have also a reimplementation of elixir_uuid | Hex and uuid_utils | Hex . Not released yet, but if it can help I make a release. GitHub - hrzndhrn/ex_uuid: UUID generator according to RFC 4122

entone

entone

There are quite a few forks of the repo, you could look into those. Forks · zyro/elixir-uuid · GitHub

If a library hasn’t been updated in a while, maybe the author has moved on, I’ll also look at open pull requests to see if anyone has made the changes I need, and can move to that version. Pull requests · zyro/elixir-uuid · GitHub

If the changes I want haven’t been made, then I make them :slight_smile: yay open source!

tcoopman

tcoopman

There are other options like About — Uniq v0.6.1

mayel

mayel

Yet another option (as an alternative to UUID, with the benefit of encoding a timestamp and thus being sortable by creation date): GitHub - omgnetwork/ex_ulid: Universally Unique Lexicographically Sortable Identifier (ULID) in Elixir

Where Next?

Popular in Questions Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement