How to make two unique fields in a schema

So I'm trying to make a plugin with many to many relationship. I want it to have teamId and branchId columns. the combination of teamId & branchId must be unqiue, how can I achieve that?
schema: {
teamOnBranch: {
fields: {
teamId: {
type: "string",
required: true,
references: {
model: "team",
field: "id",
},
},
branchId: {
type: "string",
required: true,
references: {
model: "branch",
field: "id",
},
},
assignedAt: {
type: "date",
required: true,
},
},
},
}
schema: {
teamOnBranch: {
fields: {
teamId: {
type: "string",
required: true,
references: {
model: "team",
field: "id",
},
},
branchId: {
type: "string",
required: true,
references: {
model: "branch",
field: "id",
},
},
assignedAt: {
type: "date",
required: true,
},
},
},
}
So I want the code snippet that results to the output in the prisma schema I sent (or any other ORM)
No description
1 Reply
Ping
Ping2w ago
Add unique: true to both teamId and branchId.

Did you find this page helpful?