Skip to content

Commit 0b489a0

Browse files
authored
Merge pull request #160 from strongloop/revert-157-eslint
Revert "Add eslint infrastructure"
2 parents 392610c + 4334060 commit 0b489a0

20 files changed

+561
-567
lines changed

.eslintrc

Lines changed: 0 additions & 14 deletions
This file was deleted.

example/app.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
// This file is licensed under the Artistic License 2.0.
44
// License text available at https://opensource.org/licenses/Artistic-2.0
55

6-
'use strict';
76
var DataSource = require('loopback-datasource-juggler').DataSource;
87

98
var config = require('rc')('loopback', {dev: {postgresql: {}}}).dev.postgresql;
109

1110
var ds = new DataSource(require('../'), config);
1211

1312
function show(err, models) {
14-
if (err) {
15-
console.error(err);
16-
} else {
17-
models.forEach(function(m) {
18-
console.dir(m);
19-
});
20-
}
13+
if (err) {
14+
console.error(err);
15+
} else {
16+
models.forEach(function(m) {
17+
console.dir(m);
18+
});
19+
}
2120
}
2221

22+
2323
ds.discoverModelDefinitions({views: true, limit: 20}, show);
2424

2525
ds.discoverModelProperties('product', show);
@@ -60,4 +60,6 @@ ds.discoverAndBuildModels('INVENTORY', {owner: 'STRONGLOOP', visited: {}, associ
6060
});
6161
});
6262
63+
6364
*/
65+

example/model.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Node module: loopback-connector-postgresql
33
// This file is licensed under the Artistic License 2.0.
44
// License text available at https://opensource.org/licenses/Artistic-2.0
5-
'use strict';
65
var SG = require('strong-globalize');
76
var g = SG();
87

@@ -14,33 +13,34 @@ var ds = new DataSource(require('../'), config);
1413

1514
// Define a account model
1615
var Account = ds.createModel('account', {
17-
name: String,
18-
emails: [String],
19-
age: Number},
16+
name: String,
17+
emails: [String],
18+
age: Number},
2019
{strict: true});
2120

2221
ds.automigrate('account', function(err) {
2322
// Create two instances
24-
Account.create({
23+
Account.create({
2524
name: 'John1',
2625
27-
age: 30,
28-
}, function(err, account1) {
26+
age: 30
27+
}, function (err, account1) {
2928
console.log('Account 1: ', account1.toObject());
3029
Account.create({
31-
name: 'John2',
32-
33-
age: 30,
34-
}, function(err, account2) {
35-
console.log('Account 2: ', account2.toObject());
36-
Account.findById(account2.id, function(err, account3) {
37-
console.log(account3.toObject());
38-
});
39-
Account.find({where: {name: 'John1'}, limit: 3}, function(err, accounts) {
40-
accounts.forEach(function(c) {
41-
console.log(c.toObject());
30+
name: 'John2',
31+
32+
age: 30
33+
}, function (err, account2) {
34+
console.log('Account 2: ', account2.toObject());
35+
Account.findById(account2.id, function(err, account3) {
36+
console.log(account3.toObject());
37+
});
38+
Account.find({where: {name: 'John1'}, limit: 3}, function(err, accounts) {
39+
accounts.forEach(function(c) {
40+
console.log(c.toObject());
41+
});
4242
});
43-
});
4443
});
45-
});
44+
45+
});
4646
});

index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// This file is licensed under the Artistic License 2.0.
44
// License text available at https://opensource.org/licenses/Artistic-2.0
55

6-
'use strict';
76
var SG = require('strong-globalize');
87
SG.SetRootDir(__dirname);
98

lib/discovery.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// This file is licensed under the Artistic License 2.0.
44
// License text available at https://opensource.org/licenses/Artistic-2.0
55

6-
'use strict';
76
var g = require('strong-globalize')();
87

98
module.exports = mixinDiscovery;
@@ -57,6 +56,7 @@ function mixinDiscovery(PostgreSQL) {
5756
function queryViews(options) {
5857
var sqlViews = null;
5958
if (options.views) {
59+
6060
var owner = options.owner || options.schema;
6161

6262
if (options.all && !owner) {
@@ -82,24 +82,24 @@ function mixinDiscovery(PostgreSQL) {
8282
* @param {Object} options Options for discovery
8383
* @param {Function} [cb] The callback function
8484
*/
85-
PostgreSQL.prototype.discoverModelDefinitions = function(options, cb) {
85+
PostgreSQL.prototype.discoverModelDefinitions = function (options, cb) {
8686
if (!cb && typeof options === 'function') {
8787
cb = options;
8888
options = {};
8989
}
9090
options = options || {};
9191

9292
var self = this;
93-
var calls = [function(callback) {
93+
var calls = [function (callback) {
9494
self.execute(queryTables(options), callback);
9595
}];
9696

9797
if (options.views) {
98-
calls.push(function(callback) {
98+
calls.push(function (callback) {
9999
self.execute(queryViews(options), callback);
100100
});
101101
}
102-
async.parallel(calls, function(err, data) {
102+
async.parallel(calls, function (err, data) {
103103
if (err) {
104104
cb(err, data);
105105
} else {
@@ -135,7 +135,7 @@ function mixinDiscovery(PostgreSQL) {
135135
owner: options.owner || options.schema,
136136
table: table,
137137
options: options,
138-
cb: cb,
138+
cb: cb
139139
};
140140
}
141141

@@ -148,17 +148,15 @@ function mixinDiscovery(PostgreSQL) {
148148
function queryColumns(owner, table) {
149149
var sql = null;
150150
if (owner) {
151-
sql = paginateSQL('SELECT table_schema AS "owner", table_name AS "tableName", column_name AS "columnName",'
152-
+ 'data_type AS "dataType", character_maximum_length AS "dataLength", numeric_precision AS "dataPrecision",'
153-
+ ' numeric_scale AS "dataScale", is_nullable AS "nullable"'
151+
sql = paginateSQL('SELECT table_schema AS "owner", table_name AS "tableName", column_name AS "columnName", data_type AS "dataType",'
152+
+ ' character_maximum_length AS "dataLength", numeric_precision AS "dataPrecision", numeric_scale AS "dataScale", is_nullable AS "nullable"'
154153
+ ' FROM information_schema.columns'
155154
+ ' WHERE table_schema=\'' + owner + '\''
156155
+ (table ? ' AND table_name=\'' + table + '\'' : ''),
157156
'table_name, ordinal_position', {});
158157
} else {
159-
sql = paginateSQL('SELECT current_schema() AS "owner", table_name AS "tableName", column_name AS "columnName",'
160-
+ ' data_type AS "dataType", character_maximum_length AS "dataLength", numeric_precision AS "dataPrecision",'
161-
+ ' numeric_scale AS "dataScale", is_nullable AS "nullable"'
158+
sql = paginateSQL('SELECT current_schema() AS "owner", table_name AS "tableName", column_name AS "columnName", data_type AS "dataType",'
159+
+ ' character_maximum_length AS "dataLength", numeric_precision AS "dataPrecision", numeric_scale AS "dataScale", is_nullable AS "nullable"'
162160
+ ' FROM information_schema.columns'
163161
+ (table ? ' WHERE table_name=\'' + table + '\'' : ''),
164162
'table_name, ordinal_position', {});
@@ -173,19 +171,19 @@ function mixinDiscovery(PostgreSQL) {
173171
* @param {Function} [cb] The callback function
174172
*
175173
*/
176-
PostgreSQL.prototype.discoverModelProperties = function(table, options, cb) {
174+
PostgreSQL.prototype.discoverModelProperties = function (table, options, cb) {
177175
var args = getArgs(table, options, cb);
178176
var owner = args.owner;
179177
table = args.table;
180178
options = args.options;
181179
cb = args.cb;
182180

183181
var sql = queryColumns(owner, table);
184-
var callback = function(err, results) {
182+
var callback = function (err, results) {
185183
if (err) {
186184
cb(err, results);
187185
} else {
188-
results.map(function(r) {
186+
results.map(function (r) {
189187
r.type = mysqlDataTypeToJSONType(r.dataType, r.dataLength);
190188
});
191189
cb(err, results);
@@ -194,6 +192,7 @@ function mixinDiscovery(PostgreSQL) {
194192
this.execute(sql, callback);
195193
};
196194

195+
197196
// http://docs.oracle.com/javase/6/docs/api/java/sql/DatabaseMetaData.html#getPrimaryKeys(java.lang.String, java.lang.String, java.lang.String)
198197

199198
/*
@@ -239,7 +238,7 @@ function mixinDiscovery(PostgreSQL) {
239238
* @param {Object} options The options for discovery
240239
* @param {Function} [cb] The callback function
241240
*/
242-
PostgreSQL.prototype.discoverPrimaryKeys = function(table, options, cb) {
241+
PostgreSQL.prototype.discoverPrimaryKeys = function (table, options, cb) {
243242
var args = getArgs(table, options, cb);
244243
var owner = args.owner;
245244
table = args.table;
@@ -297,7 +296,7 @@ function mixinDiscovery(PostgreSQL) {
297296
* @param {Object} options The options for discovery
298297
* @param {Function} [cb] The callback function
299298
*/
300-
PostgreSQL.prototype.discoverForeignKeys = function(table, options, cb) {
299+
PostgreSQL.prototype.discoverForeignKeys = function (table, options, cb) {
301300
var args = getArgs(table, options, cb);
302301
var owner = args.owner;
303302
table = args.table;
@@ -342,7 +341,7 @@ function mixinDiscovery(PostgreSQL) {
342341
* @param {Object} options The options for discovery
343342
* @param {Function} [cb] The callback function
344343
*/
345-
PostgreSQL.prototype.discoverExportedForeignKeys = function(table, options, cb) {
344+
PostgreSQL.prototype.discoverExportedForeignKeys = function (table, options, cb) {
346345
var args = getArgs(table, options, cb);
347346
var owner = args.owner;
348347
table = args.table;
@@ -386,19 +385,21 @@ function mixinDiscovery(PostgreSQL) {
386385
}
387386
}
388387

388+
389389
/**
390390
* Discover database indexes for the specified table
391391
* @param {String} table The table name
392392
* @param {Function} [cb] The callback function
393393
*/
394-
PostgreSQL.prototype.discoverModelIndexes = function(model, cb) {
394+
PostgreSQL.prototype.discoverModelIndexes = function (model, cb) {
395395
this.getTableStatus(model, function(err, fields, indexes) {
396396
var indexData = {};
397-
indexes.forEach(function(index) {
397+
indexes.forEach(function (index) {
398398
indexData[index.name] = index;
399399
delete index.name;
400400
});
401401
cb(err, indexData);
402402
});
403-
};
403+
}
404+
404405
}

0 commit comments

Comments
 (0)