drift-org / backend

2 stars 0 forks source link

Use mongo index for usernames in group model #42

Open brandonLi8 opened 3 years ago

brandonLi8 commented 3 years ago

We currently query the usernames to check for uniqueness, and the concern is that this is costly. Using mongo index for usernames in group model would make this really fast, and it looks super simple to set up.

See https://docs.mongodb.com/manual/indexes. For groups, we can use https://docs.mongodb.com/manual/core/index-multikey/ for indexes on arrays. Use the unique option: https://docs.mongodb.com/drivers/node/fundamentals/indexes/#unique-indexes