Generate a DDL schema from yaml description
- For SQL database
- Auto increment handled for MySQL, SQL Server, SQLITE
- Soon support for MongoDB
npm install yaml2ddl
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' })
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
MIT