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.

...