Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@anephenix/mcg

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anephenix/mcg

Model Component Generator for Objection.js

  • 0.0.3
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Model Component Generator

npm version CircleCI Coverage Status Maintainability

A Node.js library and CLI for generating Objection.js Models and their supporting files. It helps to save time creating Models and their migrations, so that you can focus on implementing the business logic for your Node.js server-side project.

Features

  • Creates an Objection.js model file via the commandline
  • Creates the model's knex.js migration file for the model's database table
  • Create a test model file in the tests folder by default
  • Create a test seed data file in the tests/data folder by default

Dependencies

Install

npm i @anephenix/mcg

Usage

You can use MCG via the command line:

npx mcg Post

This will do the following:

  • Create a folder called models, unless it already exists
  • Create a model file called Post.js in the models folder
  • Create a folder called migrations, unless it already exists
  • Generate a migration file to create the posts table with the created_at and updated_at timestamp fields.

You can pass the following optional arguments:

--testFolder - specify a custom folder name to put the test model file and seed data file in (e.g. test, spec) --mainDir - specify a custom folder path to generate all of the files in, in case your app's code is not in the current working directory --tableName - specify a custom database table name for the model and migration file (.e.g. blog_posts)

There is also the option of setting these optional arguments in a mcg.config.js file that looks like this:

module.exports = {
	testFolder: 'spec',
	mainDir: 'app',
};

You can also use MCG programmatically, like this:

const mcg = require('@anephenix/mcg');
(async () => {
	await mcg('Post');
})();

The mainDir and testFolder are optional 2nd and 3rd arguments to that command:

const path = require('path');
const mcg = require('@anephenix/mcg');
(async () => {
	const mainDir = path.join(process.cwd(), 'app');
	const testFolder = 'spec';
	await mcg('Post', mainDir, testFolder);
})();

License and Credits

©2020 Anephenix OÜ. MCG is licensed under the MIT license.

Keywords

FAQs

Package last updated on 05 Sep 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc