1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-02 22:49:09 +02:00

Api: Resolves #1956: Allow getting the resources of a note

This commit is contained in:
Laurent Cozic
2019-10-07 09:57:24 +02:00
parent 6460907976
commit 60c1939d26
2 changed files with 20 additions and 3 deletions

View File

@@ -150,8 +150,8 @@ class BaseModel {
});
}
static load(id) {
return this.loadByField('id', id);
static load(id, options = null) {
return this.loadByField('id', id, options);
}
static shortId(id) {
@@ -250,7 +250,8 @@ class BaseModel {
static loadByField(fieldName, fieldValue, options = null) {
if (!options) options = {};
if (!('caseInsensitive' in options)) options.caseInsensitive = false;
let sql = `SELECT * FROM \`${this.tableName()}\` WHERE \`${fieldName}\` = ?`;
if (!options.fields) options.fields = '*';
let sql = `SELECT ${this.db().escapeFields(options.fields)} FROM \`${this.tableName()}\` WHERE \`${fieldName}\` = ?`;
if (options.caseInsensitive) sql += ' COLLATE NOCASE';
return this.modelSelectOne(sql, [fieldValue]);
}