Skip to content

samuelmanzanera/yaml2ddl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yaml2ddl

npm version

Generate a DDL schema from yaml description

Support

  • For SQL database
    • Auto increment handled for MySQL, SQL Server, SQLITE
  • Soon support for MongoDB

Installation

npm install yaml2ddl

Usage

const yaml2dll = require('yaml2dll')

// Generate from file
const schemaFileUri = './user.table.yaml'
yaml2dll.generateFromFile(schemaFileUri, { dialect: 'mysql' })
  .then()
  .catch()

//Generate from source
const sqlGenerated = yaml2dll.generate(yamlSource, { dialect: 'mysql' })

Schema example

table: user
constraints:
    - columns: 
        - id
      name: PK_User
      type: primary
columns:
    - name: id
        type: 
          datatype: int
        options:
            notnull: true
            autoincrement: true
    - name: email
        type: 
          datatype: varchar
          length: 100

Licence

MIT

About

Generate a DDL schema from yaml description

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published