title: Ensure unique field value in loopback model
body: <p>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 loopback to through an error, on duplicate key insertion.</p>
  
  <pre><code>{
    "name": "Post",
    "plural": "Post",
    "base": "PersistedModel",
    "properties": {
      "genericId": {
        "type": "string",
        "required":True 
      },
      "moderatedAt": {
        "type": "date"
      }
    },
    "validations": [],
    "acls": [],
    "methods": []
  }
  </code></pre>
  
  <p>I have tried searching there documentation, and other examples but no success.
  One solution which I can think of is, to create a remoteHook for the create function, and validate this field before inserting, but looking for some other way.</p>