Ability to set unique entities in the database

We only have one unique entity in the user collection - email. I would like to have ability to set more than one unique entities, for ex. username.

There are two similar/related threads to this:

I’d like an auto-increment number field starting at a developer specified starting number (e.g. 1000) for use in situations like Orders and an Order Reference, for example.

Glenn McWhinney: Hi Glenn, have you found a solution for this? I’m also trying to create unique order id on an action. Hoping to use for Zapier Webhook.

Jeffrey Michael: Hey there. Nope! I used the random function in the end so I have Order Refs like: SO-1432432 and SO-9865435.

Glenn McWhinney: nice! This should work for me. Can the same random number be shared between 2 collection? Ex: Order and Items in Order ?

Jeffrey Michael: Yes I don’t see why not! You would need to set it in the Orders collection first then access it via Current Order when creating the Order Items. Something like that

Glenn McWhinney: This is great for what I need but how do you ensure the number is unique?

AJ: Well, there is a chance that the same number gets picked twice but there’s a 1 in 9 million chance of that happening in this example so the odds are in your favour :slight_smile:

Glenn McWhinney: Thanks Glenn I will roll with this for now

Any chance that anyone has figured out how to have two unique fields when creating an account? I’d love to have a unique username AND Email.
Thanks!