mongoose_schema-json
Convert mongoose schema object to JSON and vice versa.
Installation
npm install mongoose_schema-json
Usage
For example when you want to store mongoose schema in mongo database you need to convert it into JSON string.
Example of conversion
// mongoose schema in object notation var schemaObj = name: type: String lowercase: true age: Number born: Date isActive: Boolean fans: SchemaTypesMixed company_id: SchemaTypesObjectId
// mongoose schema in JSON notation var jsonStr =
Methods
- schema2json()
- json2schema()
var convert = ; var jsonStr = convert;var schemaObj = convert;
Testing
Test results will be visible in console. NodeJS must be installed !
$ node test schema2json schema1
$ node test json2schema json1