Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate model from exists database in Sails JS?

Tags:

sails.js

I begin with SailsJS and MySQL, and I have many tables in my database. So, I don't know that in SailsJS has a tool to generate models from database like Database First in Entity Framework (ASP)

like image 652
Kai N. Avatar asked Dec 02 '15 04:12

Kai N.


2 Answers

You should use, it's very good to auto generate model base DB existing.
https://www.npmjs.com/package/sails-generate-models

like image 114
Quy Le Avatar answered Oct 10 '22 18:10

Quy Le


SailsJS does not have such a tool implemented.

Though, it should not be hard to create that yourself since MySQL's SHOW COLUMNS FROM table works quite well. Then you'd just have to create the .js model files.

Be wary of the configuration in config/models.js and set migrate to safe as you might drop some columns if you haven't tested and are not sure if you've generated the models correctly.

like image 38
Andrius Avatar answered Oct 10 '22 16:10

Andrius