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

Improved handling of multiple sync targets

This commit is contained in:
Laurent Cozic
2017-07-16 13:53:59 +01:00
parent cd6d8ce284
commit 24f61177d1
21 changed files with 206 additions and 121 deletions

View File

@@ -40,7 +40,11 @@ class Database {
escapeField(field) {
if (field == '*') return '*';
return '`' + field + '`';
let p = field.split('.');
if (p.length == 1) return '`' + field + '`';
if (p.length == 2) return p[0] + '.`' + p[1] + '`';
throw new Error('Invalid field format: ' + field);
}
escapeFields(fields) {
@@ -145,9 +149,23 @@ class Database {
if (s == 'INTEGER') s = 'INT';
return this['TYPE_' + s];
}
if (type == 'syncTarget') {
if (s == 'memory') return 1;
if (s == 'file') return 2;
if (s == 'onedrive') return 3;
}
throw new Error('Unknown enum type or value: ' + type + ', ' + s);
}
static enumName(type, id) {
if (type == 'syncTarget') {
if (id === 1) return 'memory';
if (id === 2) return 'file';
if (id === 3) return 'onedrive';
}
throw new Error('Unknown enum type or id: ' + type + ', ' + id);
}
static formatValue(type, value) {
if (value === null || value === undefined) return null;
if (type == this.TYPE_INT) return Number(value);