medolino / mongoose-schema-parser Goto Github PK
View Code? Open in Web Editor NEWParse mongoose schema to JSON format
Parse mongoose schema to JSON format
When using following schema
const SchedulerSchema = new Schema({ crontabParsed: { second: Array, minute: Array, hour: Array, monthday: Array, month: Array, weekday: Array }, });
output is
Scheduler: { schema: crontabParsed: { type: 'Object', schema: { second: { type: 'Function' }, minute: { type: 'Function' }, hour: { type: 'Function' }, monthday: { type: 'Function' }, month: { type: 'Function' }, weekday: { type: 'Function' } } }
but should be
Scheduler: { schema: crontabParsed: { type: 'Object', schema: { second: { type: 'Array' }, minute: { type: 'Array' }, hour: { type: 'Array' }, monthday: { type: 'Array' }, month: { type: 'Array' }, weekday: { type: 'Array' } } }
When using this plugin to parse mongoose schemas, _id field is not present in output
When parsing properties that are of type [ObjectId]
field ref
is not copied to exported schema when it should be
example of schema
{ items: { type: [ObjectId], ref: 'Item' } }
expected output:
{ items: { type: 'ArrayOfObjectId', details: { ref: 'Item' } }, _id: { type: 'ObjectId' } }
actual output:
{ items: { type: 'ArrayOfObjectId' }, _id: { type: 'ObjectId' } }
If schema is
const ApplicationVersionSchema = new Schema({ environmentVariables: { type: {} } });
it is read as
ApplicationVersion: { schema: { environmentVariables: { type: 'Object', schema: { type: { type: 'Object', schema: {} } } } } }
even though it should be read as
ApplicationVersion: { schema: { environmentVariables: { type: 'Object', schema: {} } } }
Script fails to parse schema, when one of timestamps
schema option fields is of type string
.
Example:
const SampleSchema = new Schema({
name: {
type: String
}
}, {
timestamps: {
createdAt: 'created_at',
updatedAt: false
}
})
When using following schema
const AnalysisSchema = new Schema({ sort: [{ name: { type: String, trim: true, required: 'missing_name', maxlength: 250 }, type: { type: String, enum: ['ASC', 'DESC'], required: 'missing_type', maxlength: 5 } }], displaySeries: [{ yAxis: { type: String, required: 'missing_yAxis', maxlength: 50 }, chartType: { type: mongoose.Schema.Types.NumberEnum, enum: codelistHelper.getEnums('chartTypes'), required: 'missing_chart_type' }, regressionType: { type: mongoose.Schema.Types.NumberEnum, enum: codelistHelper.getEnums('regressionTypes') } }] });
the two are read as
Analysis: { schema: { sort: { type: 'ArrayOf[object Object]' }, displaySeries: { type: 'ArrayOfObject' }, } }
even though they are both of the same type. This only happens if name is present inside sort
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.