billgloff / objection-model-generator

automagically generate all ObjectionJS models from Mysql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OMG!!!!!

Objection Model Generator is a tool to automagically generate all ObjectionJS models from Mysql data base, using the information_schema table to let us know tables, columns and BelongsToOneRelation

basic usage:

const fs = require('fs');
const ObjectionModelGenerator = require('objection-model-generator');

const main = async () => {
  let omg = new ObjectionModelGenerator({
    host: 'localhost',
    port: '3306',
    user: 'root',
    password: 'root'
  }, 'dbName');
  // you can set a prefix to filter tables or not
  let models = await omg.createModels('access_');
  await fs.writeFile('output/ms.js', models);
  console.log('\n -> file writed: output/ms.js');
}

main();

About

automagically generate all ObjectionJS models from Mysql


Languages

Language:JavaScript 85.1%Language:HTML 14.9%