Socket
Socket
Sign inDemoInstall

objection-model-generator

Package Overview
Dependencies
321
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    objection-model-generator

generate the model from mysql database


Version published
Maintainers
1
Created

Readme

Source

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 BelongsToOneRelations.


require('dotenv').config();
const fs = require('fs');
const Omg = require('objection-model-generator');

// OPTIONAL: add pluralize customization
const pluralize = require('pluralize');
pluralize.addSingularRule('mouse', 'mice');
pluralize.addSingularRule('Mouse', 'Mice');
//----

const main = async () => {
  let omg = new Omg({
    host: process.env.DB_HOST,
    port: process.env.DB_PORT,
    user: process.env.DB_USER,
    password: process.env.DB_PASS
  }, process.env.DB_NAME, '../knex'); // relative path to the knex instance, the generated file goings to require that file
  let ms = await omg.createModels();
  let path = 'src/api/models/generated.js'; // path to where goings to be created the output
  fs.writeFileSync(path, ms);
  console.log('-> file writed:', path);
  process.exit();
}

main();

Keywords

FAQs

Last updated on 02 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc