A
A
Alexey Shevchenko2019-11-21 13:19:15
MongoDB
Alexey Shevchenko, 2019-11-21 13:19:15

How to bind an id counter to multiple MongoDB models using mongo-auto-increment?

I'm using the mongoose-auto-increment package for a more human looking _id on mongodb entries.
Is it possible to bind the counter created by this package to several models at once?
For example - there is a Post model and a Comment model. It is necessary to make sure that when creating a new Post, it is assigned, for example, id = 1, and when creating a new Comment, id = 2, etc.
If this cannot be done within the framework of this package, please tell me if there are ready-made solutions that can provide this functionality?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question