MongoDB automatically creates a unique index called `_id` for every document that is inserted into a collection. This `_id` acts as the primary key of the document and ensures that no two documents within a collection have the same value for `_id`.
If you do not provide an `_id` value in the document to be inserted, MongoDB will create a unique ObjectId value for `_id`. But, if you want to define your own custom primary key, you can provide an `_id` with your preferred unique value while inserting data.
Here’s an example how you can specify your own `_id`:
```
db.collection.insertOne({
_id: “myUniqueValue”,
“field1”: “value1”,
“field2”: “value2“
});
```
In this case, `myUniqueValue` acts as the primary key for the inserted document. Just keep in mind that `_id` value needs to be unique within the collection, else MongoDB will throw a duplicate key error.