Q: Set options to array field in Mongoose schema How can I pass options such as required: true or default to an Array field?
See the documentation here, it only shows examples like this one:
ArrayOfString: [String]

But I want to be able to do something like this:
ArrayOfString: { type: [String], required: true, default: ['one', 'two', 'three'] }

Maybe thats valid, but there are no examples like that one in the documentation.

A: Am using it with Mongoose version 2.4.9 and it works with the following syntax
ArrayOfString: {type: Array, default: ['a','b','c','d']}


A: As far as I know, mongoose doesn't introspect into arrays to figure out if they're sparse or whatever. That's probably something you'd have to do with a pre-save hook.
Edit: I may have misunderstood your question. Are you just purely looking for the presence of any array in the field?
