1.0.0 • Published 5 months ago

@easygrating/model-to-file v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@easygrating/model-to-file

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

Options

OptionAliasDescription
modelmThe name of the model you want to export.
extension (optional)eFile/language extension for the output class file. Defaults to .ts. Supports ts, js, py, php, java and cs.
path (optional)p, sequelize-pathPath 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, helpDisplay 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