On this page本页内容
Generates a BSON UUID object.生成BSON UUID对象。
UUID()
has the following syntax:具有以下语法:
UUID(<string>)
hex | string |
mongosh , UUID() required a hexadecimal string argument. mongosh 中,UUID() 需要十六进制字符串参数。 |
Create a 36 character string you wish to convert to a UUID:创建要转换为UUID的36个字符串:
var myuuid = '3b241101-e2bb-4255-8caf-4136c566a962'
The following command outputs the 以下命令将myuuid
variable as a BSON UUID object:myuuid
变量输出为BSON UUID对象:
UUID(myuuid)
This command generates the following output:该命令生成以下输出:
UUID("3b241101-e2bb-4255-8caf-4136c566a962")
You can run the 您可以在不指定参数的情况下运行UUID()
method without specifying an argument to generate a random UUID:UUID()
方法来生成随机UUID:
UUID()
This command outputs a random UUID in the following form:该命令以以下形式输出随机UUID:
UUID("dee11d4e-63c6-4d90-983c-5c9f1e79e96c")