How to set a primary key in MongoDB?

Viewed 173475

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

9 Answers

If you're using Mongo on Meteor, you can use _ensureIndex:

CollectionName._ensureIndex({field:1 }, {unique: true});
Related