trilium/src/routes/api/autocomplete.js

20 lines
403 B
JavaScript
Raw Normal View History

2018-04-18 12:26:42 +08:00
"use strict";
2018-06-06 07:12:52 +08:00
const noteCacheService = require('../../services/note_cache');
2018-04-18 12:26:42 +08:00
async function getAutocomplete(req) {
const query = req.query.query;
2018-06-06 07:12:52 +08:00
const results = noteCacheService.findNotes(query);
2018-04-18 12:26:42 +08:00
return results.map(res => {
return {
value: res.title + ' (' + res.path + ')',
2018-06-06 10:47:47 +08:00
label: res.title
2018-04-18 12:26:42 +08:00
}
});
}
module.exports = {
getAutocomplete
};