Facebook
From Adrian Pietrzak, 2 Years ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 210
  1.   function getAccountBill() {
  2.     const accountBill = `2222${Math.floor(
  3.       Math.random() * 90000000000000000000,
  4.     ) + 10000000000000000000}`;
  5.  
  6.     Bill.findOne({
  7.       where: {
  8.         account_bill: accountBill,
  9.       },
  10.     })
  11.       .then(isAccountBill => {
  12.         if (!isAccountBill) {
  13.           getAccountBill();
  14.         }
  15.         return accountBill;
  16.       })
  17.       .catch(err => {
  18.         /* just ignore */
  19.       });
  20.   }