allow flexible fields to accept single and default to many

This commit is contained in:
Dan Ribbens
2019-10-31 10:45:01 -04:00
parent ecca6e3e1f
commit e8d3eba9cb

View File

@@ -51,7 +51,7 @@ const fieldToSchemaMap = {
};
},
flexible: (field, path) => {
return [{
const schema = {
value: {
type: mongoose.Types.ObjectId,
autopopulate: true,
@@ -59,7 +59,8 @@ const fieldToSchemaMap = {
},
blockType: { type: String, enum: field.blocks },
_id: false,
}];
};
return field.hasMany !== false ? [schema] : schema;
},
};