Auto increment doesn't work, with two fields unique on Loopback

Viewed 292

I works on Loopback and have automigration works fine. But, I need config a model with two unique identifiers.

With this config

 "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 = is primary key, is not AUTO INCREMENT

VerificationCode = is primary key

Any idea? thanks

1 Answers

you can keep multiple keys in loopback using numbering the id element as follow "id": 1, "id": 2 , and you can just keep another unique key using validatesUniquenessOf() method in your js file

Related