can’t figure out how to use this identifier in any way? In SQL it was somehow clearer, there are just numbers, but here ..
Answer 1, authority 100%
MongoDB does not support transactionality , so using numeric IDs ( namely, auto-increment primary keys) is highly undesirable. In theory, this can be done, for example like this , but it makes little sense.
ObjectId is a 12 byte hex string that consists of UNIX Timestamp, machine id, process id, and a random counter. This gives such an identifier uniqueness and the ability to sort by it. So, in fact, it can do everything the same as a numeric id in MySQL, only instead of an integer you will have a hexadecimal.
From the experience of working with projects that came to me with numerical ID specialists in Mong, I can say with confidence that even with a slight increase in the load, support for such an architecture turns into hell. Duplicate records constantly appear, records in the database are mixed with each other, auto-increment jumps, and it is almost impossible to work with this.
If you have specific questions or problems when working with such id – ask more specifically.
See also: BSON Types
I just added another identifier that I use as in sql, I read somewhere that the standard id can be configured. I don’t remember exactly how, it’s like using mongoose if the project is on nodejs