Including properties, types, etc? What I'm looking to get, in essence:
{
label: {
type: "String",
required: true
},
published: {
type: "Boolean",
default: true
}
}
Calling mongoose.model('someModel').schema.paths
only returns the property type for String
, Number
, and ObjectId
, all others are undefined
. When I read up on this in the GitHub issue queue it seemed that this info (the schema.paths[path].instance
property) was internal and shouldn't even be used in the first place.
If that's the case, how can one get the schema definition programmatically?
Related questions that don't answer this:
- How to get Schema of mongoose database which defined in another model
- getting schema attributes from Mongoose Model
Related GitHub issue: