I have a data set in MongoDB that involves a large set of emails and I need to be able to add emails to the set and being able to check if certain emails are in the set. I thought of doing with document structure like this:
{'key': 'foo', 'emails':['[email protected]','[email protected]', ...]}
and use $addToSet and $in. But the problem is that Mongo has 4MB document limit and if there's a lot of emails it could be not enough. I could split it info key/email parts but I'm worried it would make both matching (since emails aren't in one place now) and inserting (since I'd need to check for uniqueness) slower. So, what would be the best way to do this?