mirror of
https://github.com/zadam/trilium.git
synced 2025-03-03 18:49:27 +08:00
sync WIP
This commit is contained in:
parent
5df3b78abc
commit
5253f680f6
2 changed files with 18 additions and 11 deletions
|
@ -3,20 +3,15 @@
|
|||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const sql = require('../../services/sql');
|
||||
const audit_category = require('../../services/audit_category');
|
||||
const auth = require('../../services/auth');
|
||||
|
||||
router.get('/', auth.checkApiAuth, async (req, res, next) => {
|
||||
const dict = {};
|
||||
router.get('/changed/:since', auth.checkApiAuth, async (req, res, next) => {
|
||||
const since = parseInt(req.params.since);
|
||||
|
||||
const settings = await sql.getResults("SELECT opt_name, opt_value FROM options WHERE opt_name IN ("
|
||||
+ ALLOWED_OPTIONS.map(x => '?').join(",") + ")", ALLOWED_OPTIONS);
|
||||
|
||||
for (const set of settings) {
|
||||
dict[set['opt_name']] = set['opt_value'];
|
||||
}
|
||||
|
||||
res.send(dict);
|
||||
res.send({
|
||||
'tree': await sql.getResults("select * from notes_tree where date_modified >= ?", [since]),
|
||||
'notes': await sql.getFlattenedResults('note_id', "select note_id from notes where date_modified >= ?", [since])
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = router;
|
|
@ -39,6 +39,17 @@ async function getResults(query, params = []) {
|
|||
return await db.all(query, ...params);
|
||||
}
|
||||
|
||||
async function getFlattenedResults(key, query, params = []) {
|
||||
const list = [];
|
||||
const result = await getResults(query, params);
|
||||
|
||||
for (const row of result) {
|
||||
list.push(row[key]);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
async function execute(query, params = []) {
|
||||
return await db.run(query, ...params);
|
||||
}
|
||||
|
@ -76,6 +87,7 @@ module.exports = {
|
|||
insert,
|
||||
getSingleResult,
|
||||
getResults,
|
||||
getFlattenedResults,
|
||||
execute,
|
||||
executeScript,
|
||||
getOption,
|
||||
|
|
Loading…
Reference in a new issue