0 votes
in MongoDB by
How to set a primary key  in MongoDB?

1 Answer

0 votes
by

I want to set one of my fields as the primary key. I am using MongoDB as my NoSQL.

The _id field is reserved for primary key in mongodb, and that should be an unique value. If you don’t set anything to _id it will automatically fill it with “MongoDB Id Object”. But you can put any unique info into that field. Additional info: https://www.mongodb.org/display/DOCS/BSON Hope it helps.

Related questions

0 votes
asked Mar 22, 2020 in Big Data | Hadoop by SakshiSharma
0 votes
asked Nov 21, 2021 in MongoDB by DavidAnderson
...