{"id":23537496,"url":"https://github.com/smikodanic/mongoose_schema-json","last_synced_at":"2025-05-15T00:20:53.562Z","repository":{"id":57302350,"uuid":"70907752","full_name":"smikodanic/mongoose_schema-json","owner":"smikodanic","description":"Convert mongoose schema object to JSON, and vice versa.","archived":false,"fork":false,"pushed_at":"2016-10-15T15:14:39.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T11:15:14.222Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smikodanic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-14T12:22:26.000Z","updated_at":"2016-10-14T16:15:14.000Z","dependencies_parsed_at":"2022-09-02T18:23:00.799Z","dependency_job_id":null,"html_url":"https://github.com/smikodanic/mongoose_schema-json","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smikodanic%2Fmongoose_schema-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smikodanic%2Fmongoose_schema-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smikodanic%2Fmongoose_schema-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smikodanic%2Fmongoose_schema-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smikodanic","download_url":"https://codeload.github.com/smikodanic/mongoose_schema-json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254249264,"owners_count":22039037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-26T03:15:48.501Z","updated_at":"2025-05-15T00:20:48.523Z","avatar_url":"https://github.com/smikodanic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongoose_schema-json\n\u003e Convert mongoose schema object to JSON and vice versa.\n\n## Installation\n`npm install mongoose_schema-json`\n\n## Usage\nFor example when you want to store mongoose schema in mongo database you need to convert it into JSON string.\n\n\n## Example of conversion\n\n```javascript\n// mongoose schema in object notation\n\nvar schemaObj = {\n\tname: {type: String, lowercase: true},\n\tage: Number,\n\tborn: Date,\n\tisActive: Boolean,\n\tfans: [Schema.Types.Mixed],\n\tcompany_id: Schema.Types.ObjectId\n}\n```\n\n```json\n// mongoose schema in JSON notation\n\nvar jsonStr = {\n\t\"name\": {\"type\": \"String\", \"lowercase\": true},\n\t\"age\": \"Number\",\n\t\"born\": \"Date\",\n\t\"isActive\": \"Boolean\",\n\t\"fans\": [\"Schema.Types.Mixed\"],\n\t\"company_id\": \"Schema.Types.ObjectId\"\n}\n```\n\n## Methods\n\n- schema2json()\n- json2schema()\n\n```javascript\nvar convert = require('mongoose_schema-json');\n\nvar jsonStr = convert.schema2json(schemaObj);\nvar schemaObj = convert.json2schema(jsonStr);\n```\n\n## Testing\nTest results will be visible in console.\nNodeJS must be installed !\n\n\n`$ node test schema2json schema1`\n\n`$ node test json2schema json1`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmikodanic%2Fmongoose_schema-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmikodanic%2Fmongoose_schema-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmikodanic%2Fmongoose_schema-json/lists"}