title: Concurrent ID generation with Loopback
body: <p>I try to generate unique identifier for some model, but if I send two or more CREATE request from the client to the API, I end up with the same id</p>
  
  <p>`</p>
  
  <pre><code>Model.observe('before save', function(
    ctx, next) {
    Model.find({
          where: {
            parentId: parentId
          }
        }, limit: 1, order:
        'numberIndex DESC'
      },
      function(err, res) {
        let idx = res[0].numberIndex + 1;
        ctx.instance['identifier'] = 'SomePrefix' + idx;
        ctx.instance['numberIndex'] =idx;
        next()
      })
  })
  `
  </code></pre>