Mongoose schema optional fields

All fields in a mongoose schema are optional by default (besides _id, of course).

A field is only required if you add required: true to its definition.

So define your schema as the superset of all possible fields, adding required: true to the fields that are required.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)