Skip to content

Commit af8d603

Browse files
committed
Lint
1 parent 5f12c91 commit af8d603

File tree

9 files changed

+153
-153
lines changed

9 files changed

+153
-153
lines changed

lib/Create.js

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ exports.CreateQuery = CreateQuery;
77
* @returns {string}
88
*/
99
var tmpl = function (template, args) {
10-
var has = {}.hasOwnProperty;
11-
for (var key in args) {
12-
if (!has.call(args, key)) {
13-
continue;
14-
}
15-
var token = '{{' + key + '}}';
16-
template = template.split(token).join(args[key]);
17-
}
10+
var has = {}.hasOwnProperty;
11+
for (var key in args) {
12+
if (!has.call(args, key)) {
13+
continue;
14+
}
15+
var token = '{{' + key + '}}';
16+
template = template.split(token).join(args[key]);
17+
}
1818

19-
return template;
19+
return template;
2020
};
2121
/**
2222
* Builds a list of fields according to the used dialect
@@ -25,20 +25,20 @@ var tmpl = function (template, args) {
2525
* @returns {string}
2626
*/
2727
var buildFieldsList = function (dialect, structure) {
28-
if (!structure) {
29-
return "";
30-
}
31-
var tpl = "'{{NAME}}' {{TYPE}}", fields = [], has = {}.hasOwnProperty;
32-
for (var field in structure) {
33-
if (has.call(structure, field)) {
34-
fields.push(tmpl(tpl, {
35-
NAME: field,
36-
TYPE: dialect.DataTypes[structure[field]]
37-
}));
38-
}
39-
}
28+
if (!structure) {
29+
return "";
30+
}
31+
var tpl = "'{{NAME}}' {{TYPE}}", fields = [], has = {}.hasOwnProperty;
32+
for (var field in structure) {
33+
if (has.call(structure, field)) {
34+
fields.push(tmpl(tpl, {
35+
NAME: field,
36+
TYPE: dialect.DataTypes[structure[field]]
37+
}));
38+
}
39+
}
4040

41-
return fields.join(',');
41+
return fields.join(',');
4242
};
4343

4444
/**
@@ -49,64 +49,64 @@ var buildFieldsList = function (dialect, structure) {
4949
* @constructor
5050
*/
5151
function CreateQuery(Dialect, opts) {
52-
var sql = {};
53-
var tableName = null;
54-
var structure = {};
52+
var sql = {};
53+
var tableName = null;
54+
var structure = {};
5555

56-
return {
57-
/**
58-
* Set the table name
59-
* @param table_name
60-
* @returns {*}
61-
*/
62-
table: function (table_name) {
63-
tableName = table_name;
56+
return {
57+
/**
58+
* Set the table name
59+
* @param table_name
60+
* @returns {*}
61+
*/
62+
table: function (table_name) {
63+
tableName = table_name;
6464

65-
return this;
66-
},
67-
/**
68-
* Add a field
69-
* @param name
70-
* @param type
71-
* @returns {Object}
72-
*/
73-
field: function (name, type) {
74-
structure[name] = type;
65+
return this;
66+
},
67+
/**
68+
* Add a field
69+
* @param name
70+
* @param type
71+
* @returns {Object}
72+
*/
73+
field: function (name, type) {
74+
structure[name] = type;
7575

76-
return this;
77-
},
78-
/**
79-
* Set all the fields
80-
* @param fields
81-
* @returns {Object}
82-
*/
83-
fields: function (fields) {
84-
if (!fields) {
85-
return structure;
86-
}
87-
structure = fields;
76+
return this;
77+
},
78+
/**
79+
* Set all the fields
80+
* @param fields
81+
* @returns {Object}
82+
*/
83+
fields: function (fields) {
84+
if (!fields) {
85+
return structure;
86+
}
87+
structure = fields;
8888

89-
return this;
90-
},
89+
return this;
90+
},
9191

92-
/**
93-
* Build a query from the passed params
94-
* @returns {string}
95-
*/
96-
build: function () {
97-
var query, fieldsList, template = "CREATE TABLE '{{TABLE_NAME}}'({{FIELDS_LIST}})";
92+
/**
93+
* Build a query from the passed params
94+
* @returns {string}
95+
*/
96+
build: function () {
97+
var query, fieldsList, template = "CREATE TABLE '{{TABLE_NAME}}'({{FIELDS_LIST}})";
9898

99-
if(!tableName){
100-
return '';
101-
}
99+
if(!tableName){
100+
return '';
101+
}
102102

103-
fieldsList = buildFieldsList(Dialect, structure);
103+
fieldsList = buildFieldsList(Dialect, structure);
104104

105-
return tmpl(template, {
106-
TABLE_NAME: tableName,
107-
FIELDS_LIST: fieldsList
108-
});
105+
return tmpl(template, {
106+
TABLE_NAME: tableName,
107+
FIELDS_LIST: fieldsList
108+
});
109109

110-
}
111-
};
110+
}
111+
};
112112
}

lib/Dialects/mssql.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ var util = require("util");
22
var helpers = require("../Helpers");
33

44
exports.DataTypes = {
5-
id: 'INT IDENTITY(1,1) NOT NULL PRIMARY KEY',
6-
int: 'INT',
7-
float: 'FLOAT',
8-
bool: 'BIT',
9-
text: 'TEXT'
5+
id: 'INT IDENTITY(1,1) NOT NULL PRIMARY KEY',
6+
int: 'INT',
7+
float: 'FLOAT',
8+
bool: 'BIT',
9+
text: 'TEXT'
1010
};
1111

1212

@@ -25,7 +25,7 @@ exports.escapeId = function () {
2525
return exports.escapeVal(el.escapes.shift());
2626
});
2727
}
28-
return "[" + el + "]";
28+
return "[" + el + "]";
2929
}).join(".");
3030
};
3131

lib/Dialects/mysql.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ var util = require("util");
22
var helpers = require("../Helpers");
33

44
exports.DataTypes = {
5-
id: 'INTEGER PRIMARY KEY AUTO_INCREMENT',
6-
int: 'INTEGER',
7-
float: 'FLOAT(12,2)',
8-
bool: 'TINYINT(1)',
9-
text: 'TEXT'
5+
id: 'INTEGER PRIMARY KEY AUTO_INCREMENT',
6+
int: 'INTEGER',
7+
float: 'FLOAT(12,2)',
8+
bool: 'TINYINT(1)',
9+
text: 'TEXT'
1010
};
1111

1212

lib/Dialects/postgresql.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ var util = require("util");
22
var helpers = require("../Helpers");
33

44
exports.DataTypes = {
5-
id: 'SERIAL PRIMARY KEY',
6-
int: 'INTEGER',
7-
float: 'REAL',
8-
bool: 'SMALLINT',
9-
text: 'TEXT'
5+
id: 'SERIAL PRIMARY KEY',
6+
int: 'INTEGER',
7+
float: 'REAL',
8+
bool: 'SMALLINT',
9+
text: 'TEXT'
1010
};
1111

1212

lib/Dialects/sqlite.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ var helpers = require("../Helpers");
33

44

55
exports.DataTypes = {
6-
isSQLITE: true,
7-
id: 'INTEGER PRIMARY KEY AUTOINCREMENT',
8-
int: 'INTEGER',
9-
float: 'FLOAT(12,2)',
10-
bool: 'TINYINT(1)',
11-
text: 'TEXT'
6+
isSQLITE: true,
7+
id: 'INTEGER PRIMARY KEY AUTOINCREMENT',
8+
int: 'INTEGER',
9+
float: 'FLOAT(12,2)',
10+
bool: 'TINYINT(1)',
11+
text: 'TEXT'
1212
};
1313

1414
exports.escape = function (query, args) {

lib/Helpers.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,49 +16,49 @@ module.exports.escapeQuery = function (Dialect, query, args) {
1616
}
1717

1818
module.exports.dateToString = function (date, timeZone, opts) {
19-
var dt = new Date(date);
19+
var dt = new Date(date);
2020

21-
if (timeZone != 'local') {
22-
var tz = convertTimezone(timeZone);
21+
if (timeZone != 'local') {
22+
var tz = convertTimezone(timeZone);
2323

24-
dt.setTime(dt.getTime() + (dt.getTimezoneOffset() * 60000));
25-
if (tz !== false) {
26-
dt.setTime(dt.getTime() + (tz * 60000));
27-
}
28-
}
24+
dt.setTime(dt.getTime() + (dt.getTimezoneOffset() * 60000));
25+
if (tz !== false) {
26+
dt.setTime(dt.getTime() + (tz * 60000));
27+
}
28+
}
2929

30-
var year = dt.getFullYear();
31-
var month = zeroPad(dt.getMonth() + 1);
32-
var day = zeroPad(dt.getDate());
33-
var hour = zeroPad(dt.getHours());
34-
var minute = zeroPad(dt.getMinutes());
35-
var second = zeroPad(dt.getSeconds());
36-
var milli = zeroPad(dt.getMilliseconds(), 3);
30+
var year = dt.getFullYear();
31+
var month = zeroPad(dt.getMonth() + 1);
32+
var day = zeroPad(dt.getDate());
33+
var hour = zeroPad(dt.getHours());
34+
var minute = zeroPad(dt.getMinutes());
35+
var second = zeroPad(dt.getSeconds());
36+
var milli = zeroPad(dt.getMilliseconds(), 3);
3737

38-
if (opts.dialect == 'mysql') {
39-
return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second + '.' + milli;
40-
} else {
41-
return year + '-' + month + '-' + day + 'T' + hour + ':' + minute + ':' + second + '.' + milli + 'Z';
42-
}
38+
if (opts.dialect == 'mysql') {
39+
return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second + '.' + milli;
40+
} else {
41+
return year + '-' + month + '-' + day + 'T' + hour + ':' + minute + ':' + second + '.' + milli + 'Z';
42+
}
4343
}
4444

4545
function zeroPad(number, n) {
46-
if (arguments.length == 1) n = 2;
46+
if (arguments.length == 1) n = 2;
4747

48-
number = "" + number;
48+
number = "" + number;
4949

50-
while (number.length < n) {
51-
number = "0" + number;
52-
}
53-
return number;
50+
while (number.length < n) {
51+
number = "0" + number;
52+
}
53+
return number;
5454
}
5555

5656
function convertTimezone(tz) {
57-
if (tz == "Z") return 0;
57+
if (tz == "Z") return 0;
5858

59-
var m = tz.match(/([\+\-\s])(\d\d):?(\d\d)?/);
60-
if (m) {
61-
return (m[1] == '-' ? -1 : 1) * (parseInt(m[2], 10) + ((m[3] ? parseInt(m[3], 10) : 0) / 60)) * 60;
62-
}
63-
return false;
59+
var m = tz.match(/([\+\-\s])(\d\d):?(\d\d)?/);
60+
if (m) {
61+
return (m[1] == '-' ? -1 : 1) * (parseInt(m[2], 10) + ((m[3] ? parseInt(m[3], 10) : 0) / 60)) * 60;
62+
}
63+
return false;
6464
}

lib/Query.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ function Query(opts) {
2727
escape : Helpers.escapeQuery.bind(Helpers, Dialect),
2828
escapeId : Dialect.escapeId.bind(Dialect),
2929
escapeVal : Dialect.escapeVal.bind(Dialect),
30-
create: function(){
31-
return new CreateQuery(Dialect, opts);
32-
},
30+
create: function(){
31+
return new CreateQuery(Dialect, opts);
32+
},
3333
select: function () {
3434
return new SelectQuery(Dialect, opts);
3535
},

lib/Select.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,24 @@ function SelectQuery(Dialect, opts) {
105105

106106
var a, f = from_id, t;
107107
if (arguments.length == 3) {
108-
a = sql.from[sql.from.length - 1].a;
109-
t = to_table;
108+
a = sql.from[sql.from.length - 1].a;
109+
t = to_table;
110110
} else {
111-
a = get_table_alias(to_table);
112-
t = to_id;
111+
a = get_table_alias(to_table);
112+
t = to_id;
113113
}
114114

115115
from.j = [];
116116
if (f.length && t.length) {
117-
if (Array.isArray(f) && Array.isArray(t) && f.length == t.length) {
118-
for (i = 0; i < f.length; i++) {
119-
from.j.push([f[i], a, t[i]]);
120-
}
121-
} else {
122-
from.j.push([f, a, t]);
123-
}
117+
if (Array.isArray(f) && Array.isArray(t) && f.length == t.length) {
118+
for (i = 0; i < f.length; i++) {
119+
from.j.push([f[i], a, t[i]]);
120+
}
121+
} else {
122+
from.j.push([f, a, t]);
123+
}
124124
} else {
125-
throw new Error();
125+
throw new Error();
126126
}
127127

128128
sql.from.push(from);

0 commit comments

Comments
 (0)