var schemaGenerator = new require('mongoose-schema').Jso nSchemaGenerator();
var jsonSchema = schemaGenerator.generate(mongo oseSchema);
Hi
how to return a mongoose schema as JSON? for example convert:var InfoSchema = new Schema({ name: { type: String, required: true }, title: { type: String, required: true, trim: true } });
to somthing like:schema = { type: "object", properties: { name: { type: "string"}, title: { type: "string" } };
YourSchema.paths
YourModel.schema.paths
You can overwrite the toJSON method on those objects if you want.
댓글 없음:
댓글 쓰기