motzM
Convex Community6mo ago
2 replies
motz

Short IDs for Rooms table

Hi there, I'm migrating off of Postgres to Convex.
In my application, I have a rooms table that contains a kind of "Code" you can use to join the room. It has 4 alphanumeric digits (just uppercase letters and numbers), so that's 36^4 combinations.

Previously I used the sequential room id and generated a short_id using pg_hashids, but as it seems there is no such thing in Convex, because every document id is globally (to the project) unique.

How should I go about generating a "random" 4-digit string that has to be unique in the rooms table?

PS: If you happen to know Jackbox, these kinds of room codes are exactly what I'm going for.
Was this page helpful?