Skip to content

Instantly share code, notes, and snippets.

@utsukushiihime
Forked from bnoguchi/enum-access.js
Created September 22, 2020 23:29
Show Gist options
  • Save utsukushiihime/1944fef0d37621fd0cec8f6cbb89c200 to your computer and use it in GitHub Desktop.
Save utsukushiihime/1944fef0d37621fd0cec8f6cbb89c200 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