MongoDB에 users collection을 생성하고 회원가입 기능을 만들고 있었다.
email값이 중복되면 DB 저장 시 에러를 뱉어주고 싶다.

원하는 Collection에서 Indexes 탭 -> CREATE INDEX 클릭

Create Index 화면에서 사진 아래쪽 설명과 같이 작성 (예를들어 email을 unique key로 만들고 싶을 때)

Fields
{
"email": 1
}
Options
{
"unique": true
}
Adding full-text search to your application? Instead of creating a text index, consider a search index. Atlas Search offers faster performance, more expressive queries, and options to fine-tune relevance. Create Search Index


다음에는 백앤드쪽 코드의 에러 처리를 추가해야 한다. :)