1.0.3 • Published 5 years ago

typeorm-schema-to-json-schema v1.0.3

Weekly downloads
169
License
MIT
Repository
github
Last release
5 years ago

typeorm-schema-to-json-schema

NPM version license

standard

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' }
//   }
// }
1.0.3

5 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago