How to share enum values in mongoose shema?
You can define const for each kind
, and use it in both: schema and router:
// consts.jsconst KIND0 = 0;const KIND1 = 1;...const KIND10 = 1;const KINDS = [KIND0, KIND1,...,KIND10];// schema.jskind: { type: Number, enum: KINDS}// router.jsModel.create({ kind: KIND10 }).exec(callback);