dimanche 29 mars 2020

Exposing Internal IDs to Users vs. Having 2 IDs on a Single Schema?

Wondering whether this is bad practice:

I'm working on an app, where users will be able to type in the id of a component and jump to that component. I will make sure that these ids will be unique & are kept short: e.g. : XXD-1, XXD-2 etc. - so that users can remember them.

However, my app is internally also making use of ids.

The question is now whether I should make the ids I am using internally (in my database in the backend, but also as refs & keys in react, redux etc.) the same ids that I expose to the user?

Or should my component have 2 separate ids: One which serves as a proper id in my database, generated by Mongo etc., and one that I expose to the user, that's sort of a pseud-id, short and memorable? I am wondering what advantages / disadvantages each approach has.

{
  id: '1201203172637612637172312887', //generated by mongodb, for example,
  mycoolappId: 'XXD-2', //just short and memorable, for users to engage with
}

I feel it might make sense to have a single id to work with and having 2 ids feels redundant, on the other hand it makes sense to me, and it would be way less prone to error, if I have the proper ids generated by mongo.

PS: I am not sure how to best tag this question, so feel free to edit the tags!

Aucun commentaire:

Enregistrer un commentaire