mirror of
https://github.com/zadam/trilium.git
synced 2025-11-04 20:36:13 +01:00
sql console added to global menu and now has schema info
This commit is contained in:
@@ -2,6 +2,20 @@
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
|
||||
async function getSchema() {
|
||||
const tableNames = await sql.getColumn(`SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name`);
|
||||
const tables = [];
|
||||
|
||||
for (const tableName of tableNames) {
|
||||
tables.push({
|
||||
name: tableName,
|
||||
columns: await sql.getRows(`PRAGMA table_info(${tableName})`)
|
||||
});
|
||||
}
|
||||
|
||||
return tables;
|
||||
}
|
||||
|
||||
async function execute(req) {
|
||||
const query = req.body.query;
|
||||
|
||||
@@ -20,5 +34,6 @@ async function execute(req) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getSchema,
|
||||
execute
|
||||
};
|
||||
Reference in New Issue
Block a user