You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
743 B
21 lines
743 B
import { knex } from '../../lib/ormish.js';
|
|
import { API } from '../../lib/api.js';
|
|
|
|
export const get = async (req, res) => {
|
|
const api = new API(req, res);
|
|
|
|
if(!api.admin_authenticated) {
|
|
return api.error(401, "Admin rights required.");
|
|
} else {
|
|
// NOTE: in lib/ormish.js the schema is loaded once, but I do it every time
|
|
// here to reflect the current database even if they haven't restarted it yet
|
|
let result = await knex("sqlite_schema").where({"type": "table"}).select(['type', 'name']).orderBy('name');
|
|
|
|
for(let table of result) {
|
|
table._columns = await knex(table.name).columnInfo();
|
|
}
|
|
|
|
// TODO: flag that the database has changed so they know to restart
|
|
return api.reply(200, result);
|
|
}
|
|
}
|
|
|