(str: string)
| 20 | }); |
| 21 | |
| 22 | function random(str: string) { |
| 23 | const numbers = Math.floor(1000 + Math.random() * 9000); |
| 24 | if (str.match(/-\d{4}$/g)) { |
| 25 | return str.replace(/-\d{4}$/g, `-${numbers}`); |
| 26 | } |
| 27 | return `${str}-${numbers}`; |
| 28 | } |
| 29 | |
| 30 | if (existingProject) { |
| 31 | return getId(tableName, random(name)); |