typeorm-schema-to-json-schema
v1.0.3
Published
Typeorm entitySchema to json schema.
Downloads
94
Readme
typeorm-schema-to-json-schema
Typeorm entitySchema to json schema.
Install
npm install typeorm-schema-to-json-schema
Get started
Cat model
const { EntitySchema } = require('typeorm') const Cat = new EntitySchema({ name: 'cats', columns: { id: { type: Number, primary: true, generated: true }, name: { type: String } } }) module.exports = Cat
convert model
const convert = require('typeorm-schema-to-json-schema')
const Cat = require('./cat')
const schema = convert(Cat)
console.log(schema)
// {
// type: 'object',
// properties: {
// id: { type: 'number', primary: true, generated: true },
// name: { type: 'string' }
// }
// }