Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何在环回中为设备生成和存储UUDI_Node.js_Loopbackjs_Loopback - Fatal编程技术网

Node.js 如何在环回中为设备生成和存储UUDI

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"){

我想创建一个web服务来生成UUID,并将其与环回一起存储在一个类似的表中

token和uuid的函数运行良好,但我不知道应该将uuid放置在何处,例如,获取token并将其存储在表中

 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": {}
}