Reputation: 4811
How can i make the Unique key as a combination of 3 columns in loopback model The model structure is like
"properties": {
"year": {
"type": "number",
"required": true
},
"user_id": {
"type": "number",
"required": true
},
"leave_type_id": {
"type": "number",
"required": true
},
"total_days": {
"type": "number",
"required": true
}
},
And for me the year,User_id,leave_type_id combination is going to be a unique key . How can i mention that in the loop back model definition
Upvotes: 0
Views: 1364
Reputation: 2781
Define multiple id
properties on the field.
...
"user_id": {
"id": 1, //add this
"type": "number",
"required": true
},
"leave_type_id": {
"id": 2, //add this
"type": "number",
"required": true
},
...
Upvotes: 4