How to make user's email unique in mongoDB?

后端 未结 3 1206
刺人心
刺人心 2021-01-01 16:01

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         


        
3条回答
  •  旧时难觅i
    2021-01-01 16:57

    You can do it by creating a unique index for your email field.

    http://docs.mongodb.org/manual/tutorial/create-a-unique-index/

提交回复
热议问题