I'm trying to get a solution to add a number to a string on insert to column in database if the string is duplicated.
For example, i have a table test with the unique column name. I want to, when running this code
INSERT INTO test (name) VALUES (example)
INSERT INTO test (name) VALUES (example)
INSERT INTO test (name) VALUES (example)
The values inserted turn out
- example
- example-1
- example-2
Is it possible to do this directly on the database or is it better to do it on the api (Node.JS) that connects to the database?