Question

I was wondering if you can get the metadata or the entire structure of the table and columns using sailsjs or waterline's mysql module

Was it helpful?

Solution

After hours of searching, I've finally found the holy grail. Well half of the holy grail. Anyway, I just followed the instructions given here: https://github.com/balderdashy/sails/issues/780 then created my own custom query.

OTHER TIPS

Yes its very easy to get structure of MySQL table by Waterline SalsJS...

Model.query("desc table_name",function (err, models) {
        if(!err)
          {
              //Do somethng wth your data in models variable
          }
      }
    )

Here table_name is your table name

For me, below code was working fine...

db('users_table').query("SHOW COLUMNS FROM users_table",function (err, models) {
        if (! err )
            // working with data
      });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top