Skip to content

Automatically create JSON like model structures - can be easily modified for Sequelize or Waterline

Notifications You must be signed in to change notification settings

servo1/mysqlAutoModels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mysqlAutoModels

Automatically create JSON like model structures - can be easily modified for Sequelize or Waterline

It will generate definitions for most common column types as well as create references for foreign keys (for table joins, relationships, etc...).

Simply include and pass in connection, database, per table callback and final callback.

function saveModels(model){
	fs.writeFile(modelsPath + model.def.name + ".js", JSON.stringify(model, null, 2), function(err) {
		//do something with result here?
		console.log(modelsPath + model.def.name + ".js", err);
	});
}

modeler.init(connection, 'mydb', saveModels, function(err){
	if (err) console.log("err: ", err);
	else console.log("done - check your file output directory for schemas");
})

You can check test.js for a working implementation. Should work with rowsAsArray or without. If you are getting object property/array reference errors, simply check the section starting at line 34 where the various property references are defined.

About

Automatically create JSON like model structures - can be easily modified for Sequelize or Waterline

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published