Introduction
Every document in MongoDB needs a unique _id. Using custom _id values lets you control this unique identifier instead of letting MongoDB create one automatically.
When you want to use meaningful IDs like usernames or email addresses as the document ID.
When you need to link documents across collections using a known ID.
When importing data from another system that already has unique IDs.
When you want to avoid the extra space of MongoDB's default ObjectId.
When you want to quickly find documents by a known key without extra indexing.