Skip to content

apaichon/codegenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

codegenerator

I developed an app with Featherjs, which in the real work I did, There are more than two hundred tables. I was too lazy to create patterns repeatedly since starting sequence and tables in the Postgres and Featherjs model, class, service, so I developed a program for generating code to reduce the development time.

The steps are as follows.

  1. Download this code.
  2. Prepare a list of objects that you want to generate.
   generateList/itemList.json
Item Description
objects Class name, service, table, hook, configure (feather), table (postgres), sequence (postgres)
models Specifies the database data type field name.
  • Currently supports only data types. int => INTEGER,timestamp => DATE, bool => Boolean by default is STRING

Example

{
 "objects":
 [
   "users",
   "request_licenses",
   "request_license_upload_files",
   "files",
   "file_streams",
   "payment_header",
   "payment_detail"
  ],
  "models":
  [
    
     "payment_header": [
       {"field":"id","dataType":"int","isRequired":"Y"},
       {"field":"member_id","dataType":"int","isRequired":"Y"},
       {"field":"document_type_id","dataType":"smallint","isRequired":"Y"},
       {"field":"document_ref_id","dataType":"varchar(50)","isRequired":"Y"},
       {"field":"payment_date","dataType":"timestamp","isRequired":"Y"},
       {"field":"payment_method_id","dataType":"smallint","isRequired":"Y"},
       {"field":"payment_ref_id","dataType":"varchar(50)","isRequired":""},
       {"field":"total_price","dataType":"numeric(18,6)","isRequired":"Y"},
       {"field":"total_tax","dataType":"numeric(18,6)","isRequired":"Y"},
       {"field":"total_amount","dataType":"numeric(18,6)","isRequired":"Y"},
       {"field":"createdAt","dataType":"timestamp","isRequired":"Y"},
       {"field":"createdBy","dataType":"varchar(255)","isRequired":"Y"},
       {"field":"updatedAt","dataType":"timestamp","isRequired":""},
       {"field":"updatedBy","dataType":"varchar(255)","isRequired":""},
       {"field":"status_id","dataType":"smallint","isRequired":"Y"}
     ],
       "file_streams": [
       {"field":"id","dataType":"int","isRequired":"Y"},
       {"field":"file_id","dataType":"int","isRequired":"Y"},
       {"field":"stream_position","dataType":"int","isRequired":"Y"},
       {"field":"file_contents","dataType":"bytea[]","isRequired":"Y"},
       {"field":"createdAt","dataType":"timestamp","isRequired":"Y"},
       {"field":"createdBy","dataType":"varchar(255)","isRequired":"Y"},
       {"field":"updatedAt","dataType":"timestamp","isRequired":""},
       {"field":"updatedBy","dataType":"varchar(255)","isRequired":""}
     ]
 
  ]
 }
  1. Prepare a configuration.
config.json
Item Description
outputFolder Root output folder.
owner For postgres database owner.
schema For Postgres database schema.
templateFile
/template/featherClass.js
For Generate Feather Class.
/template/featherModel.js
For Generate Feather Model.
/template/featherService.js
For Generate Feather Service.
/template/featherRegister.js
For Register Feather Service.
/template/postgresMasterTable.sql
For Generate Create Table sql of Postgres
/template/postgresSequence.sql
For Generate Create Sequence sql of Postgres
genType
class
For Generate Feather Class.
model
For Generate Feather Model.
service
For Generate Feather Service.
configure
For Register Feather Service.
table
For Generate Create Table sql of Postgres
sequence
For Generate Create Sequence sql of Postgres
provider
feather
For Featherjs
postgre
For Postgres
  1. Run it.
node index
  1. Got your files !!!

Made your happy.

About

Include the Generate code that I have developed.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published