Yes, adding a unique index to a field is almost always the best way to ensure its uniqueness in the collection.
When using a compound index, MongoDB ensures that each doc in the collection has a unique combination of field values. So if you only had a compound unique index over company
and email
, you could have more than one doc with the same company
or email
, just as long as the combination of the two is unique.