1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

API: Resolves #1148: Added support for search end-point and improved error handling

This commit is contained in:
Laurent Cozic
2019-02-24 12:24:55 +00:00
parent 179005dd6c
commit 50b75e1e63
4 changed files with 26 additions and 4 deletions

View File

@ -3,15 +3,17 @@ const Note = require('lib/models/Note');
class SearchEngineUtils {
static async notesForQuery(query) {
static async notesForQuery(query, options = null) {
if (!options) options = {};
const results = await SearchEngine.instance().search(query);
const noteIds = results.map(n => n.id);
const previewOptions = {
const previewOptions = Object.assign({}, {
order: [],
fields: Note.previewFields(),
conditions: ['id IN ("' + noteIds.join('","') + '")'],
}
}, options);
const notes = await Note.previews(null, previewOptions);