You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
First pass at linting lib dir
This commit is contained in:
@ -6,7 +6,6 @@ const { sprintf } = require('sprintf-js');
|
||||
const Mutex = require('async-mutex').Mutex;
|
||||
|
||||
class Database {
|
||||
|
||||
constructor(driver) {
|
||||
this.debugMode_ = false;
|
||||
this.driver_ = driver;
|
||||
@ -48,7 +47,7 @@ class Database {
|
||||
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);
|
||||
}
|
||||
|
||||
@ -152,7 +151,7 @@ class Database {
|
||||
if (type == 'fieldType') {
|
||||
if (s) s = s.toUpperCase();
|
||||
if (s == 'INTEGER') s = 'INT';
|
||||
if (!(('TYPE_' + s) in this)) throw new Error('Unkonwn fieldType: ' + s);
|
||||
if (!('TYPE_' + s in this)) throw new Error('Unkonwn fieldType: ' + s);
|
||||
return this['TYPE_' + s];
|
||||
}
|
||||
if (type == 'syncTarget') {
|
||||
@ -183,12 +182,12 @@ class Database {
|
||||
|
||||
sqlStringToLines(sql) {
|
||||
let output = [];
|
||||
let lines = sql.split("\n");
|
||||
let lines = sql.split('\n');
|
||||
let statement = '';
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var line = lines[i];
|
||||
if (line == '') continue;
|
||||
if (line.substr(0, 2) == "--") continue;
|
||||
if (line.substr(0, 2) == '--') continue;
|
||||
statement += line.trim();
|
||||
if (line[line.length - 1] == ',') statement += ' ';
|
||||
if (line[line.length - 1] == ';') {
|
||||
@ -214,7 +213,7 @@ class Database {
|
||||
static insertQuery(tableName, data) {
|
||||
if (!data || !Object.keys(data).length) throw new Error('Data is empty');
|
||||
|
||||
let keySql= '';
|
||||
let keySql = '';
|
||||
let valueSql = '';
|
||||
let params = [];
|
||||
for (let key in data) {
|
||||
@ -272,7 +271,7 @@ class Database {
|
||||
for (let n in fields) {
|
||||
if (!fields.hasOwnProperty(n)) continue;
|
||||
fieldsWithType.push(this.escapeField(n) + ' ' + fields[n]);
|
||||
}
|
||||
}
|
||||
|
||||
let sql = `
|
||||
CREATE TEMPORARY TABLE _BACKUP_TABLE_NAME_(_FIELDS_TYPE_);
|
||||
@ -288,9 +287,9 @@ class Database {
|
||||
sql = sql.replace(/_FIELDS_NO_TYPE_/g, this.escapeFields(fieldsNoType).join(','));
|
||||
sql = sql.replace(/_FIELDS_TYPE_/g, fieldsWithType.join(','));
|
||||
|
||||
return sql.trim().split("\n");
|
||||
return sql.trim().split('\n');
|
||||
}
|
||||
|
||||
|
||||
wrapQueries(queries) {
|
||||
let output = [];
|
||||
for (let i = 0; i < queries.length; i++) {
|
||||
@ -313,7 +312,6 @@ class Database {
|
||||
return sql; // Already wrapped
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Database.TYPE_UNKNOWN = 0;
|
||||
@ -321,4 +319,4 @@ Database.TYPE_INT = 1;
|
||||
Database.TYPE_TEXT = 2;
|
||||
Database.TYPE_NUMERIC = 3;
|
||||
|
||||
module.exports = { Database };
|
||||
module.exports = { Database };
|
||||
|
Reference in New Issue
Block a user