Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justin26l/json2mongoose
https://github.com/justin26l/json2mongoose
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/justin26l/json2mongoose
- Owner: Justin26l
- License: mit
- Created: 2023-12-03T09:11:06.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-09T06:43:21.000Z (3 months ago)
- Last Synced: 2024-10-09T06:45:20.845Z (3 months ago)
- Language: TypeScript
- Size: 401 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# JsonSchema to Mongoose Model Generator
This tool allows you to generate Mongoose models from JSON schemas.
## Installation
Install the package globally using npm:
```bash
npm install json2mongoose -g
```## Usage
### Command Line Interface (CLI)
To use the tool from the command line, run the following command:
```bash
json2mongoose ./jsonSchema ./output
```### Node
You can also use the tool programmatically in your Node.js scripts:
```javascript
import json2mongoose from "json2mongoose"const schemaDir = "path/to/jsonSchema";
const modelDir = "path/to/model";
const typeDir = "path/to/types";json2mongoose.genarate(schemaDir: string, modelDir: string, typeDir: string);
```Please replace the paths with the actual paths to your JSON schemas and output directory.
## Note
The generated file is named based on the schema file's name.
the `x-documentConfig.documentName` will only effect on mongoose api.
ex: docuemt interface, schema, model.if you don't wish to drop your hair after some bug came out,
match the schema file name with document name.# To Do
[] validation of json schema,
- x-foreignKey collection exist
-## License
This project is licensed under the terms of the MIT license. See the [LICENSE](LICENSE) file for details.