You've already forked joplin
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:
@@ -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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user