How to generate a globally unique string id?

recently, I learned the node.js + koa + mysql backend. When I write a page, I always see that the requested interface has some string-based unique Id,. I don"t know how to do it myself. Please give me some advice

.
Apr.07,2021

there are many ways to globally unique strings, such as time-based, network card mac address, cpu id and so on. The standard is that the uuid, generation algorithm is standardized, and almost all languages have readily available methods.

method for MySQL to generate uuid

select uuid();

there are many ways for nodejs to generate uuid, such as using the node-uuid module.

execute: npm install node-uuid first

    var uuid = require('node-uuid');
    console.log(uuid.v1())
    console.log(uuid.v4())
Menu