I am making a collection of user\'s data. This will be pretty basic consisting of user\'s email, user\'s password (hashed), and an array of strings.
{
em
Use unique keyword, or simply make _id value to be email.
db.collection.createIndex( { email: 1 }, { unique: true } )
Mongodb ensureIndex
has been deprecated, use createIndex
instead.
db.collection.createIndex( { email: 1 }, { unique: true } )
You can do it by creating a unique index for your email field.
http://docs.mongodb.org/manual/tutorial/create-a-unique-index/