trilium/src/services/search.js

40 lines
921 B
JavaScript
Raw Normal View History

const repository = require('./repository');
const sql = require('./sql');
2019-03-17 18:38:27 +08:00
const log = require('./log');
const parseFilters = require('./parse_filters');
const buildSearchQuery = require('./build_search_query');
async function searchForNotes(searchString) {
const filters = parseFilters(searchString);
const {query, params} = buildSearchQuery(filters);
2019-03-17 18:38:27 +08:00
try {
return await repository.getEntities(query, params);
}
catch (e) {
log.error("Search failed for " + query);
throw e;
}
}
async function searchForNoteIds(searchString) {
const filters = parseFilters(searchString);
const {query, params} = buildSearchQuery(filters, 'notes.noteId');
2019-03-17 18:38:27 +08:00
try {
return await sql.getColumn(query, params);
}
catch (e) {
log.error("Search failed for " + query);
throw e;
}
}
module.exports = {
searchForNotes,
searchForNoteIds
};