K
K
Konstantin2021-05-25 16:24:50
Mongoose
Konstantin, 2021-05-25 16:24:50

How to set your id to the user who will increase by 1?

How to create your own ID in the user model that would increase by one with each registration? At the moment, the built-in mongus ids have a very unpresentable look (60abf7055bd7c61cc0d6fb64), but I would like the id1, id2 and so on

.

it is possible to add two types of treatment to one request?

//чтение юзера
    router.get("/:id или ник юзера", async(req, res) => {
       ....
    })

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2021-05-25
@gradk

Could two types of appeal be added to one request?

So treat it as an ID or a nickname)) Who's stopping you?
router.get("/:idOrNickname", async(req, res) => {
    // и делаете запрос ИЛИ подставляя req.params.idOrNickname как _id и nickname
})

In general, in Google, at the request of mongoose custom id , it’s just crazy how much information. Use))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question