How to ensure uniqueness of a particular field in loopback model. Like below is the model Post, I have a field genericId in it, I want it to be unique in the database, and l
The Lookback v4 solution looks like this:
@model() export class Client extends Entity { @property({ type: 'string', required: true, index: { unique: true, }, }) name: string; }
Then you must update your schema:
npm run migrate
or recreate it:
npm run migrate -- --rebuild