Generating unique document numbers

System Information
  • Strapi Version: 3.6.8
  • Operating System: Windows 10
  • Database: Mysql
  • Node Version: 12.18.3
  • NPM Version: 7.18.1
  • Yarn Version:

Hi everyone,

I have a range of a valid numbers to be used for identifying documents. Whenever I’m going to create a document, I have to select an unused number. What is the best way to implement this? Because I’m thinking I might run into race conditions if I do someting like this :

  • query latest existing document
  • select next document number based on latest document

Thanks!