Search code examples
node.jsmongodbuidnode-uuid

Generating Unique IDs on Node.js for a Express web application


Ive come across two possible libraries node-uuid (https://www.npmjs.com/package/node-uuid) and cuid (http://usecuid.org/). Both of these from what i can see generate good collision free unique ids. However, there is the odd situation where there may be collisions as discussed in https://github.com/ericelliott/cuid/issues/22.

To over come this problem my initial thought was to store it in mongodb and look for uniqueness. Is there a better way of achieving this to get a guarantee on uniqueness ?


Solution

  • I know it does not answer you question but I am using this following library https://www.npmjs.com/package/uuid and it does not have any issue open at least. And you can find why it will not be the same in here https://softwareengineering.stackexchange.com/questions/130261/uuid-collisions