I'm working in the context of a (kind of) microservices architecture where services can have multiple instances that can create new documents in the same collection of a Mongo DB.
There is a functional requirement that each document gets a unique ID (like e.g. an employee ID or badge number). Preferably newer documents get a higher ID.
Since MongoDB doesn't have an auto-increment feature, how is this typically handled? I've seen suggestions to create a separate service that keeps track of the numbering, but I don't really like this because there can only be one instance of this service and it will need to process requests for a new number in a synchronized manner.