Loopback插入我的MongoDB的对象ID值作为序列,而不是随机的。出于安全原因,我如何将所有模型默认更改为随机?
会影响数据库性能吗?
您可以更改模型描述文件中ID的生成方式:https://loopback.io/doc/en/lb3/Model-definition-JSON-file.html#properties
model.json:
{
"name": "model",
"base": "PersistedModel",
"strict": true,
"idInjection": false, // disable default id!
"properties": {
"id": {
"id": true,
"required": true,
"type": "string",
"defaultFn": "uuid" // "guid" / "uuid" / "uuidv4" / "now"
},
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}