MongoDB UUID().toString() 出现乱码问题

216 阅读1分钟

刚接触MongoDB,一般很少在Compass上的shell使用内置函数,在调用UUID().toString()的时候发现乱码了。
WechatIMG305.jpg
不知道为什么会乱码,看到了别处的解决方法:

UUID()
    .toString('hex')
    .replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, '$1-$2-$3-$4-$5')

WechatIMG307.jpg