自动增量不起作用,两个字段在回送时是唯一的

问题描述 投票:2回答:1

我从事Loopback的工作,并且自动迁移工作正常。但是,我需要配置一个具有两个唯一标识符的模型。

使用此配置

 "properties": {
    "id": {
      "type": "Number",
      "id": true,
      "generated": true, // doesn't works
      "required": false
    },
    "verificationCode": {
      "type": "String",
      "required": true,
      "id": true,
      "length": 10,
      "mysql": {
        "columnName": "verification_code"
      }
    },

ID =是主键,不是AUTO INCREMENT

VerificationCode =是主键

有什么想法吗?谢谢

mysql loopback
1个回答
0
投票

您可以使用编号id元素的方式在回送中保留多个键,如下所示“ id”:1,“ id”:2,您可以使用保留另一个唯一键validatesUniquenessOf()js文件中的方法

© www.soinside.com 2019 - 2024. All rights reserved.