Skip to content

Instantly share code, notes, and snippets.

@jrran90
Forked from bnoguchi/enum-access.js
Created October 26, 2021 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrran90/4e1f9fdd9599bb60cd4b7baf56f3114e to your computer and use it in GitHub Desktop.
Save jrran90/4e1f9fdd9599bb60cd4b7baf56f3114e to your computer and use it in GitHub Desktop.
How to access enumValues in mongoose from a Model or Document
var mongoose = require('./index')
, TempSchema = new mongoose.Schema({
salutation: {type: String, enum: ['Mr.', 'Mrs.', 'Ms.']}
});
var Temp = mongoose.model('Temp', TempSchema);
console.log(Temp.schema.path('salutation').enumValues);
var temp = new Temp();
console.log(temp.schema.path('salutation').enumValues);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment