Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

323
Vistas
Vue JS: generate random numbers for invoice

i wanted to know the best way for generating random numbers for invoice and it shouldn't be duplicated .. in my project i'm posting invoice number for each user into API and ofc i should completely avoid duplication ... is there a way to do this in Vue js?

below i tried this code but i believe it might duplicate by chance :\

const Random = '0' + Math.ceil(Math.random()*1000000)+ moment(new Date()).format('DDMMYY');

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

As time cannot be repeated, you can use new Date().getTime()

about 4 years ago · Juan Pablo Isaza Denunciar

0

Use UUID v4

  1. Install and import UUID
import { v4 as uuidv4 } from 'uuid';
  1. Set invoice ID
invoice.id = uuidv4(); // ⇨ '14cd6bcd-bbfd-4a2d-3b5d-ab8dfcbd4dea'
  1. At the backend side, don't forget to check that the invoice id is not already used.
  2. Best way is to define a database unique key.
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda