Answer the question
In order to leave comments, you need to log in
How to make a unique slug for a page?
I'm trying to make an application on node.js. I was puzzled by the creation of beautiful url.
Now they look like this
localhost/item/574aac2fc4621ec02f12c301
I would like to do something like this
localhost/item/pervia-page
That is, now the id from mongodb is being substituted.
When added to the database, json arrives with a certain number of elements, and it can contain elements with the same name, and the database can also have such names, but everyone has different characteristics. I think you need to add a number to the end of the same slugs so that they differ. How to check that there are no identical slugs?
Answer the question
In order to leave comments, you need to log in
Generate a slug based on some criterion (title or something else, it doesn't matter) and see if it is in the database.
Your K.O.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question