How do I validate the uniqueness of a variable on a nested document across the board in Mongoose / MongoDB?

Problem

I am trying to figure out how to validate the uniqueness of a field on a nested document across the board. Say I have the following schema:

var Store = new Schema({
name : String
, employees: [{name: string, email:string}]
});

Would there be anyway to ensure that the person’s email was unique across all stores?

Problem courtesy of: Chance

Solution

I believe that you can prevent duplicates in this case using a unique index in MongoDb: http://www.mongodb.org/display/DOCS/Indexes#Indexes-UniqueIndexes. If you try to insert an employee with an existing email address, you’ll get an exception.

Solution courtesy of: Chris Shain

View additional discussion.