@easygrating/model-to-file

1.0.0 • Public • Published

@easygrating/model-to-file

Exports Sequelize models to high level programming language class files such as TypeScript, JavaScript, PHP, C#, Java and Python.

Options

Option Alias Description
model m The name of the model you want to export.
extension (optional) e File/language extension for the output class file. Defaults to .ts. Supports ts, js, py, php, java and cs.
path (optional) p, sequelize-path Path to the Sequelize index.js directory. By default search for .sequelizerc file under the execution directory or ./models/index.js file if none is found.
help (optional) h, help Display the usage guide.

Install

Install it as a global package

npm install @easygrating/model-to-file -g

Usage

Create TypeScript class from sequelize model

model-to-file --model Province --extension ts

will output Province.ts file

class Province {
    id: number;
    name: string;
    code: string;
    latitude: string;
    longitude: string;
    createdAt: Date;
    updatedAt: Date;
    Municipalities: Municipality[];
}

Create C# class from sequelize model

model-to-file --model Province --extension cs

will output Province.cs file

using System;
using System.Collections.Generic;

public class Province 
{ 
	public int Id { get; set; }
	public string Name { get; set; }
	public string Code { get; set; }
	public decimal Latitude { get; set; }
	public decimal Longitude { get; set; }
	public DateTime CreatedAt { get; set; }
	public DateTime UpdatedAt { get; set; }
	public List<Municipality> Municipalities { get; set; }
}

Keywords

sequelize, model, util, class

Readme

Keywords

Package Sidebar

Install

npm i @easygrating/model-to-file

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

27.6 kB

Total Files

20

Last publish

Collaborators

  • nacastroc
  • kingnier
  • orozco92
  • luismi930213