I am trying to have a role containing an access array.
access: [{
type: 'string',
match: /^[a-zA-Z]+$/,
required: true,
notEmpty: true,
check: {
minLength: 2
}
}]
I get:
node_modules\mongoose\lib\schema\array.js:58
this.caster = new caster(null, castOptions);
^
TypeError: string is not a function
If I replaced type: 'string'with type: String, it will work. What for? If I try to add an index to an array, it will not work. ( index: true)
Do I need to do collection.index({'access': 1})?
source
share