Skip to content

Commit 91ffb7b

Browse files
authored
Merge pull request #382 from strongloop/update-dev-deps
Update dev deps + fix linting issues
2 parents 1719a38 + be7e95c commit 91ffb7b

23 files changed

+493
-488
lines changed

deps/juggler-v3/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
'use strict';
77

8-
var should = require('../../test/init');
9-
var juggler = require('loopback-datasource-juggler');
10-
var name = require('./package.json').name;
8+
const should = require('../../test/init');
9+
const juggler = require('loopback-datasource-juggler');
10+
const name = require('./package.json').name;
1111

1212
describe(name, function() {
1313
before(function() {

deps/juggler-v4/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
'use strict';
77

8-
var should = require('../../test/init');
9-
var juggler = require('loopback-datasource-juggler');
10-
var name = require('./package.json').name;
8+
const should = require('../../test/init');
9+
const juggler = require('loopback-datasource-juggler');
10+
const name = require('./package.json').name;
1111

1212
describe(name, function() {
1313
before(function() {

example/app.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
// License text available at https://opensource.org/licenses/Artistic-2.0
55

66
'use strict';
7-
var DataSource = require('loopback-datasource-juggler').DataSource;
7+
const DataSource = require('loopback-datasource-juggler').DataSource;
88

9-
var config = require('rc')('loopback', {dev: {postgresql: {}}}).dev.postgresql;
9+
const config = require('rc')('loopback', {dev: {postgresql: {}}}).dev.postgresql;
1010

11-
var ds = new DataSource(require('../'), config);
11+
const ds = new DataSource(require('../'), config);
1212

1313
function show(err, models) {
1414
if (err) {
@@ -26,10 +26,10 @@ ds.discoverModelProperties('product', show);
2626

2727
// ds.discoverModelProperties('INVENTORY_VIEW', {owner: 'STRONGLOOP'}, show);
2828

29-
ds.discoverPrimaryKeys('inventory', show);
30-
ds.discoverForeignKeys('inventory', show);
29+
ds.discoverPrimaryKeys('inventory', show);
30+
ds.discoverForeignKeys('inventory', show);
3131

32-
ds.discoverExportedForeignKeys('product', show);
32+
ds.discoverExportedForeignKeys('product', show);
3333

3434
/*
3535

example/model.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
// License text available at https://opensource.org/licenses/Artistic-2.0
55

66
'use strict';
7-
var SG = require('strong-globalize');
8-
var g = SG();
7+
const SG = require('strong-globalize');
8+
const g = SG();
99

10-
var DataSource = require('loopback-datasource-juggler').DataSource;
10+
const DataSource = require('loopback-datasource-juggler').DataSource;
1111

12-
var config = require('rc')('loopback', {dev: {postgresql: {}}}).dev.postgresql;
12+
const config = require('rc')('loopback', {dev: {postgresql: {}}}).dev.postgresql;
1313

14-
var ds = new DataSource(require('../'), config);
14+
const ds = new DataSource(require('../'), config);
1515

1616
// Define a account model
17-
var Account = ds.createModel('account', {
17+
const Account = ds.createModel('account', {
1818
name: String,
1919
emails: [String],
2020
age: Number},
21-
{strict: true});
21+
{strict: true});
2222

2323
ds.automigrate('account', function(err) {
2424
// Create two instances

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// License text available at https://opensource.org/licenses/Artistic-2.0
55

66
'use strict';
7-
var SG = require('strong-globalize');
7+
const SG = require('strong-globalize');
88
SG.SetRootDir(__dirname);
99

1010
module.exports = require('./lib/postgresql.js');

lib/discovery.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
// License text available at https://opensource.org/licenses/Artistic-2.0
55

66
'use strict';
7-
var g = require('strong-globalize')();
7+
const g = require('strong-globalize')();
88

99
module.exports = mixinDiscovery;
1010

1111
function mixinDiscovery(PostgreSQL) {
12-
var async = require('async');
12+
const async = require('async');
1313

1414
PostgreSQL.prototype.paginateSQL = function(sql, orderBy, options) {
1515
options = options || {};
16-
var limit = '';
16+
let limit = '';
1717
if (options.offset || options.skip || options.limit) {
1818
limit = ' OFFSET ' + (options.offset || options.skip || 0); // Offset starts from 0
1919
if (options.limit) {
@@ -32,8 +32,8 @@ function mixinDiscovery(PostgreSQL) {
3232
* @returns {string} The sql statement
3333
*/
3434
PostgreSQL.prototype.buildQueryTables = function(options) {
35-
var sqlTables = null;
36-
var owner = options.owner || options.schema;
35+
let sqlTables = null;
36+
const owner = options.owner || options.schema;
3737

3838
if (options.all && !owner) {
3939
sqlTables = this.paginateSQL('SELECT \'table\' AS "type", table_name AS "name", table_schema AS "owner"'
@@ -44,7 +44,7 @@ function mixinDiscovery(PostgreSQL) {
4444
} else {
4545
sqlTables = this.paginateSQL('SELECT \'table\' AS "type", table_name AS "name",'
4646
+ ' table_schema AS "owner" FROM information_schema.tables WHERE table_schema=current_schema()',
47-
'table_name', options);
47+
'table_name', options);
4848
}
4949
return sqlTables;
5050
};
@@ -55,22 +55,22 @@ function mixinDiscovery(PostgreSQL) {
5555
* @returns {string} The sql statement
5656
*/
5757
PostgreSQL.prototype.buildQueryViews = function(options) {
58-
var sqlViews = null;
58+
let sqlViews = null;
5959
if (options.views) {
60-
var owner = options.owner || options.schema;
60+
const owner = options.owner || options.schema;
6161

6262
if (options.all && !owner) {
6363
sqlViews = this.paginateSQL('SELECT \'view\' AS "type", table_name AS "name",'
6464
+ ' table_schema AS "owner" FROM information_schema.views',
65-
'table_schema, table_name', options);
65+
'table_schema, table_name', options);
6666
} else if (owner) {
6767
sqlViews = this.paginateSQL('SELECT \'view\' AS "type", table_name AS "name",'
6868
+ ' table_schema AS "owner" FROM information_schema.views WHERE table_schema=\'' + owner + '\'',
69-
'table_schema, table_name', options);
69+
'table_schema, table_name', options);
7070
} else {
7171
sqlViews = this.paginateSQL('SELECT \'view\' AS "type", table_name AS "name",'
7272
+ ' current_schema() AS "owner" FROM information_schema.views',
73-
'table_name', options);
73+
'table_name', options);
7474
}
7575
}
7676
return sqlViews;
@@ -117,9 +117,9 @@ function mixinDiscovery(PostgreSQL) {
117117
* @param {Function} [cb] The callback function
118118
*/
119119
PostgreSQL.prototype.discoverModelProperties = function(table, options, cb) {
120-
var self = this;
121-
var args = self.getArgs(table, options, cb);
122-
var schema = args.schema;
120+
const self = this;
121+
const args = self.getArgs(table, options, cb);
122+
let schema = args.schema;
123123

124124
table = args.table;
125125
options = args.options;
@@ -131,8 +131,8 @@ function mixinDiscovery(PostgreSQL) {
131131
self.setDefaultOptions(options);
132132
cb = args.cb;
133133

134-
var sql = self.buildQueryColumns(schema, table);
135-
var callback = function(err, results) {
134+
const sql = self.buildQueryColumns(schema, table);
135+
const callback = function(err, results) {
136136
if (err) {
137137
cb(err, results);
138138
} else {
@@ -164,23 +164,23 @@ function mixinDiscovery(PostgreSQL) {
164164
* @returns {String} The sql statement
165165
*/
166166
PostgreSQL.prototype.buildQueryColumns = function(owner, table) {
167-
var sql = null;
167+
let sql = null;
168168
if (owner) {
169169
sql = this.paginateSQL('SELECT table_schema AS "owner", table_name AS "tableName", column_name AS "columnName",'
170170
+ 'data_type AS "dataType", character_maximum_length AS "dataLength", numeric_precision AS "dataPrecision",'
171171
+ ' numeric_scale AS "dataScale", is_nullable AS "nullable"'
172172
+ ' FROM information_schema.columns'
173173
+ ' WHERE table_schema=\'' + owner + '\''
174174
+ (table ? ' AND table_name=\'' + table + '\'' : ''),
175-
'table_name, ordinal_position', {});
175+
'table_name, ordinal_position', {});
176176
} else {
177177
sql = this.paginateSQL('SELECT current_schema() AS "owner", table_name AS "tableName",'
178178
+ ' column_name AS "columnName",'
179179
+ ' data_type AS "dataType", character_maximum_length AS "dataLength", numeric_precision AS "dataPrecision",'
180180
+ ' numeric_scale AS "dataScale", is_nullable AS "nullable"'
181181
+ ' FROM information_schema.columns'
182182
+ (table ? ' WHERE table_name=\'' + table + '\'' : ''),
183-
'table_name, ordinal_position', {});
183+
'table_name, ordinal_position', {});
184184
}
185185
return sql;
186186
};
@@ -193,7 +193,7 @@ function mixinDiscovery(PostgreSQL) {
193193
*
194194
*/
195195

196-
// http://docs.oracle.com/javase/6/docs/api/java/sql/DatabaseMetaData.html#getPrimaryKeys(java.lang.String, java.lang.String, java.lang.String)
196+
// http://docs.oracle.com/javase/6/docs/api/java/sql/DatabaseMetaData.html#getPrimaryKeys(java.lang.String, java.lang.String, java.lang.String)
197197

198198
/*
199199
SELECT kc.table_schema AS "owner", kc.table_name AS "tableName",
@@ -212,7 +212,7 @@ function mixinDiscovery(PostgreSQL) {
212212
* @returns {string}
213213
*/
214214
PostgreSQL.prototype.buildQueryPrimaryKeys = function(owner, table) {
215-
var sql = 'SELECT kc.table_schema AS "owner", '
215+
let sql = 'SELECT kc.table_schema AS "owner", '
216216
+ 'kc.table_name AS "tableName", kc.column_name AS "columnName",'
217217
+ ' kc.ordinal_position AS "keySeq",'
218218
+ ' kc.constraint_name AS "pkName" FROM'
@@ -260,7 +260,7 @@ function mixinDiscovery(PostgreSQL) {
260260
* @returns {string}
261261
*/
262262
PostgreSQL.prototype.buildQueryForeignKeys = function(owner, table) {
263-
var sql =
263+
let sql =
264264
'SELECT tc.table_schema AS "fkOwner", tc.constraint_name AS "fkName", tc.table_name AS "fkTableName",'
265265
+ ' kcu.column_name AS "fkColumnName", kcu.ordinal_position AS "keySeq",'
266266
+ ' ccu.table_schema AS "pkOwner",'
@@ -298,7 +298,7 @@ function mixinDiscovery(PostgreSQL) {
298298
* @returns {string}
299299
*/
300300
PostgreSQL.prototype.buildQueryExportedForeignKeys = function(owner, table) {
301-
var sql = 'SELECT kcu.constraint_name AS "fkName", kcu.table_schema AS "fkOwner", kcu.table_name AS "fkTableName",'
301+
let sql = 'SELECT kcu.constraint_name AS "fkName", kcu.table_schema AS "fkOwner", kcu.table_name AS "fkTableName",'
302302
+ ' kcu.column_name AS "fkColumnName", kcu.ordinal_position AS "keySeq",'
303303
+ ' (SELECT constraint_name'
304304
+ ' FROM information_schema.table_constraints tc2'
@@ -328,8 +328,8 @@ function mixinDiscovery(PostgreSQL) {
328328
*/
329329

330330
PostgreSQL.prototype.buildPropertyType = function(columnDefinition, dataLength) {
331-
var mysqlType = columnDefinition.dataType;
332-
var type = mysqlType.toUpperCase();
331+
const mysqlType = columnDefinition.dataType;
332+
const type = mysqlType.toUpperCase();
333333
switch (type) {
334334
case 'BOOLEAN':
335335
return 'Boolean';
@@ -369,7 +369,7 @@ function mixinDiscovery(PostgreSQL) {
369369
*/
370370
PostgreSQL.prototype.discoverModelIndexes = function(model, cb) {
371371
this.getTableStatus(model, function(err, fields, indexes) {
372-
var indexData = {};
372+
const indexData = {};
373373
indexes.forEach(function(index) {
374374
indexData[index.name] = index;
375375
delete index.name;

0 commit comments

Comments
 (0)