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 ?