Auto-create mysql table with StrongLoop

后端 未结 8 842
栀梦
栀梦 2021-02-07 11:39

I am trying to use Strongloop with MySql but cannot figure out how to migrate or automatically create tables into a MySql database.

Is there at least a way to export the

8条回答
  •  旧时难觅i
    2021-02-07 12:21

    You can simply migrate models by adding following lines to your server.js file before app.start method:

    app.datasources['mySqlConnection'].automigrate(['orders','customers', 'User', 'ACL'], function(err) {
         console.log(err);
    });
    
    1. Add models to the array as per your need.
    2. Run the application by slc run.

    Note: mySqlConnection is the connection name, replace it by your own connection name.

提交回复
热议问题