Question: how object id is generated in mongodb?
Answer: MongoDB database drivers by default generate an ObjectID identifier that is assigned to the _id field of each document. In many cases the ObjectID may be used as a unique identifier in an application. a 3-byte counter, starting with a random value.