我正在尝试从MySQL数据库获取表列表,并且代码在下面
./ server / datasources.json
{
"db": {
"host": "localhost",
"port": 3306,
"database": "xman",
"password": "toor",
"user": "root",
"connector": "mysql",
"supportBigNumbers":"true"
}
}
./ discover-table.js
'use strict';
const loopback = require('loopback');
const DATASOURCE_NAME = 'db';
const dataSourceConfig = require('./server/datasources.json');
const db = loopback.DataSource('mysql', dataSourceConfig[DATASOURCE_NAME]);
db.discoverModelDefinitions(function(err, models) {
console.log("Data " + models);
db.disconnect();
});
执行上述文件时,输出为
Data
,并且models变量包含一个空数组。如何获取数据库表列表?
注意:我正在使用环回3.x