I have a Department
model in my project. The properties are id
, name
. name
of course should be unique. However I can't seem to look where the setting is so I can put something like
@model()
export class Department extends Entity {
@property({
type: 'number',
id: true,
generated: true,
})
id?: number;
@property({
type: 'string',
required: true,
unique: true // ---> This is what I want. But how?
})
name: string;
constructor(data?: Partial<Department>) {
super(data);
}
}
I tried digging to Model documentation, it seems that there is something I can do with the @model
decorator. However I found no documentation about it.
Also, I want to do this in PostgreSQL as a datasource. Any clue? Any advice would be appreciated.