Can anyone explain the difference between Uuid::generate and DB::generateKey?

Viewed 42

Without thinking too hard about it I created a column of type [UUID] and successfully stored "strings" (as noted in the documentation, and generally referred to as a separate type altogether) returned from DB::generateKey in it.

Feels like I've done something I shouldn't have.

Can anyone share some light on this. Thanks in advance.

2 Answers

Mostly they return different types. For clarity, DB::generateKey is equivalent to Uuid::generate |> toString

According to the standard library docs, it's the return type.

Uuid::generate() -> UUID
Generate a new UUID v4 according to RFC 4122

DB::generateKey() -> Str
Returns a random key suitable for use as a DB key

I believe the UUID type is a bitstring representation, that is, a specific sequence of bits in memory.

Whereas the Str type is a string representation of a UUID.

Related