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

Api: Added method to get notes

This commit is contained in:
Laurent Cozic
2018-09-27 18:35:10 +00:00
parent 8a619e4b8b
commit ef711af5b5
7 changed files with 322 additions and 79 deletions

View File

@ -207,8 +207,9 @@ class Note extends BaseItem {
return ['id', 'title', 'body', 'is_todo', 'todo_completed', 'parent_id', 'updated_time', 'user_updated_time', 'user_created_time', 'encryption_applied'];
}
static previewFieldsSql() {
return this.db().escapeFields(this.previewFields()).join(',');
static previewFieldsSql(fields = null) {
if (fields === null) fields = this.previewFields();
return this.db().escapeFields(fields).join(',');
}
static async loadFolderNoteByField(folderId, field, value) {
@ -309,8 +310,9 @@ class Note extends BaseItem {
return this.search(options);
}
static preview(noteId) {
return this.modelSelectOne('SELECT ' + this.previewFieldsSql() + ' FROM notes WHERE is_conflict = 0 AND id = ?', [noteId]);
static preview(noteId, options = null) {
if (!options) options = { fields: null };
return this.modelSelectOne('SELECT ' + this.previewFieldsSql(options.fields) + ' FROM notes WHERE is_conflict = 0 AND id = ?', [noteId]);
}
static conflictedNotes() {