1.2.9 • Published 7 years ago

code-auto v1.2.9

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

��# Code-auto

�Ǐ}T�NL�ꁨR9hncꁚ[IN!jgub�Nx�e�N

Install

*./codeAuto.js*
npm install  code-auto

var codeAuto=require("code-auto");
const config = {
        dialect: "mysql",   penc�^{|�W�mysql�Postgres�Sqlite3�MSSQL	�
        port: '3306', �z�S��Nmysql�TPostgres	�
        host:  "127.0.0.1",  penc�^

g�RhV0W@W username: "root", penc�^&��S pwd: "password", penc�^�[x storage: "database", penc�^ T Templates: './codetpl', !jg�e�N9Y_ (!jg�[IN:N*.ct) codetype: "js" �Nx{|�W��Q�[columns�Sϑ-NCodeType � � c# || java || js � } codeAuto.run(config,function(err){ if(err){ throw new Error(err); } console.log("�[b") })

$node node codeAuto.js

�OV�

(WO(uCode-auto O���(WhQ@\�[ňcknxOO(u�vpenc�^

Example for MySQL/MariaDB

npm install -g mysql

Example for Postgres

npm install -g pg pg-hstore

Example for Sqlite3

npm install -g sqlite

Example for MSSQL

npm install -g mssql

!jg�Qn�Sϑ

    tableName�h�

T

    columns�S_MRh��v@b	gR
    columns item:
            name R

T type penc{|�W CodeType �Nx�QO(u�vpenc{|�W�9hncM�n�Nx{|�Wub� c# || java || js � � primaryKey (false || true) /f&T;N.� allowNull (false || true) /f&T�S�N:NNULL defaultValue ؞��<P

!jg�[IN

!jg�{�S+T(Wtemplate�Q � T�e(Wtemplate N�[INoutput^\'`ZP:Nub���Q

�O

<template output='./model'>
    /* jshint indent: 2 */
        module.exports = app => {
        const sequelize = app.Sequelize;
        const entity = {
            {{#columns.forEach(function(column,index){ }}
                {{column.name}}: {
                    type: {{column.CodeType}},
                    allowNull: {{column.allowNull}},
                    {{column.primaryKey?"primaryKey:"+column.primaryKey+",":""}}
                    {{column.autoIncrement?"autoIncrement:"+column.autoIncrement:""}}
                }{{index==(columns.length-1)?'':','}}
            {{# }); }}
        }
        const nav_cat = app.model.define('{{tableName}}', entity, {
            tableName: '{{tableName}}'
        });
        {{tableName}}.getModel=model=>{
                                    if(typeof model!=="object"){
                                        throw new  Error("��Bl�Spe���");
                                        return false;
                                    }
                                    let newobj={};
                                    for (var key in model) {
                                        if (entity.hasOwnProperty(key)) {
                                            newobj[key]=model[key];
                                        }
                                    }
                                return newobj;
                                }
        return {{tableName}};
        };
</template>
1.2.9

7 years ago

1.2.8

7 years ago

1.2.7

7 years ago

1.2.6

7 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago