0

The question I have is that I'm trying to auto-generate a number incrementally every time a user creates a new record. I'm trying to have the field auto-generate a number as soon as a person wants to create a new record and have it be uneditable or greyed out.

I've been looking into angular material to see if this can be done on the front end, but I'm not sure.

  • 5
    Generally the data store (database) would be responsible for this. When an *application* generates identifiers, they tend to be GUIDs rather than incrementing numbers, as the potential for race conditions is high. – David Jan 10 '23 at 20:09

1 Answers1

0

Normally it is a responsibility of back-end to generate such a number which uses as an identifier or id. How does back-end generate it depends on Database, for example MongoDB generate UUID and add it to your object. but if you insist to make it in front-end on purpose you can use uuid npm package.

import { v4 as uuidv4 } from 'uuid';
const uuid = uuidv4();
Samathingamajig
  • 11,839
  • 3
  • 12
  • 34