Reputation: 91685
I'm writing an API in Express, using Mongoose as my data layer. I'd like the API to be as self-describing as possible so my frontend can automatically generate forms and validation based on schema rules set up in my Mongoose models.
Is there any existing way to get a JSON representation of a Mongoose schema, or will I have to write my own? There seem to be plenty of JSON-to-Mongoose schema generators, but very little in the way of describing an existing schema.
Upvotes: 0
Views: 348
Reputation: 176
I probably don't get a point. You can define your schema as Object and then use JSON.stringify
on it. Or if you want, you can access all schema paths through model as Model.schema.paths
.
Upvotes: 2