title: How to add a unique constraints through Loopback 4 Model?
body: <p>I have a <code>Department</code> model in my project. The properties are <code>id</code>, <code>name</code>. <code>name</code> of course should be unique. However I can't seem to look where the setting is so I can put something like</p>
  <pre class="lang-js prettyprint-override"><code>@model()
  export class Department extends Entity {
    @property({
      type: 'number',
      id: true,
      generated: true,
    })
    id?: number;
  
    @property({
      type: 'string',
      required: true,
      unique: true // ---&gt; This is what I want. But how?
    })
    name: string;
  
    constructor(data?: Partial&lt;Department&gt;) {
      super(data);
    }
  }
  </code></pre>
  <p>I tried digging to <a href="https://loopback.io/doc/en/lb4/Model.html" rel="nofollow noreferrer">Model</a> documentation, it seems that there is something I can do with the <code>@model</code> decorator. However I found no documentation about it.</p>
  <p>Also, I want to do this in PostgreSQL as a datasource. Any clue? Any advice would be appreciated.</p>