dbrand666
unread,Jul 20, 2012, 3:10:37 PM7/20/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongoo...@googlegroups.com
My schema contains an array or strings. I want to put a unique, sparse index on this array, like so:
new Schema({
array_of_strings: {type: [String], unique: true, sparse: true}
});
The problem I'm running into is that if array_of_strings is empty, Mongoose includes the empty array in the document. This leads to duplicate key errors. It there a way to tell Mongoose not to include empty objects when writing documents?