Node.js 如何在环回中为设备生成和存储UUDI
我想创建一个web服务来生成UUID,并将其与环回一起存储在一个类似的表中 token和uuid的函数运行良好,但我不知道应该将uuid放置在何处,例如,获取token并将其存储在表中Node.js 如何在环回中为设备生成和存储UUDI,node.js,loopbackjs,loopback,Node.js,Loopbackjs,Loopback,我想创建一个web服务来生成UUID,并将其与环回一起存储在一个类似的表中 token和uuid的函数运行良好,但我不知道应该将uuid放置在何处,例如,获取token并将其存储在表中 function generateUUID() { var d = new Date().getTime(); if(window.performance && typeof window.performance.now === "function"){
function generateUUID() {
var d = new Date().getTime();
if(window.performance && typeof window.performance.now === "function"){
d += performance.now();; //use high-precision timer if available
}
var uuid = 'xxxxxxxxxxxx7xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = (d + Math.random()*16)%16 | 0;
d = Math.floor(d/16);
return (c=='x' ? r : (r&0x3|0x8)).toString(16);
});
return uuid;
};
代币
UUDI.json
"name": "UUDI",
"plural": "getuudi",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"uuid": {
"type": "string",
"required": true
},
"date": {
"type": "string",
"required": true
},
"time": {
"type": "string",
"required": true
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
可以使用环回函数属性生成uuid 检查-
"name": "UUDI",
"plural": "getuudi",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"uuid": {
"type": "string",
"required": true
},
"date": {
"type": "string",
"required": true
},
"time": {
"type": "string",
"required": true
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}