mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
cddd23f926
This frees us up to enforce one single point of access, thus paving the way towards allowing us to initialize the models at are request, and not when it's require(). addresses #2170
28 lines
No EOL
789 B
JavaScript
28 lines
No EOL
789 B
JavaScript
var _ = require('lodash'),
|
|
config = require('../../config');
|
|
|
|
function getTables() {
|
|
return config().database.knex.raw('show tables').then(function (response) {
|
|
return _.flatten(_.map(response[0], function (entry) {
|
|
return _.values(entry);
|
|
}));
|
|
});
|
|
}
|
|
|
|
function getIndexes(table) {
|
|
return config().database.knex.raw('SHOW INDEXES from ' + table).then(function (response) {
|
|
return _.flatten(_.pluck(response[0], 'Key_name'));
|
|
});
|
|
}
|
|
|
|
function getColumns(table) {
|
|
return config().database.knex.raw('SHOW COLUMNS FROM ' + table).then(function (response) {
|
|
return _.flatten(_.pluck(response[0], 'Field'));
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
getTables: getTables,
|
|
getIndexes: getIndexes,
|
|
getColumns: getColumns
|
|
}; |