Fightpandemics: Make Users.email unique

Created on 4 Jun 2020  路  7Comments  路  Source: FightPandemics/FightPandemics

Email would need to be unique across IndividualUsers & OrganizationalUsers.

We need to decide if we let Mongo handle the error OR use this library to handle with a library: https://www.npmjs.com/package/mongoose-unique-validator

BACKEND Database Individual Profile MVP - Critical MVP - Release 1 Organization Profile

Most helpful comment

I think this can be done in the model set-up, the email field should have a unique property to its field, and then we could use a the packageabove, I think, this should have been in the set-up all along from the start.

All 7 comments

IMO we should add the constraint and try to prevent the error by using a validator

@joaofnds so is using the library referenced above best or do you have another suggestion?

We can start implementing the mongoose-unique-validator or https://mongoosejs.com/docs/api/model.html#model_Model.exists,

I can start implementing the first one and see how it goes...

I think this can be done in the model set-up, the email field should have a unique property to its field, and then we could use a the packageabove, I think, this should have been in the set-up all along from the start.

what's up with this?

what's up with this?

You mean who's working on it and what's the status? Not sure. @Naraujo13 not sure if you were planning to look into this. Otherwise, @adisen feel free to take it on! (message on Slack with further details)

I'm on it, should submit a PR today!

Was this page helpful?
0 / 5 - 0 ratings