Skip to content

Commit a6d1b2c

Browse files
lint and normalize helper
1 parent 61f60c1 commit a6d1b2c

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

helpers/validate-connection.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/**
2-
* Note that this helper module exports a "wet" (i.e. ready-to-call)
3-
* machine instance; not just a dry definition.
4-
*
5-
* @type {Function}
6-
*/
71
module.exports = require('machine').build({
82

93

@@ -21,8 +15,13 @@ module.exports = require('machine').build({
2115

2216
inputs: {
2317

24-
connection:
25-
require('../constants/connection.input'),
18+
connection: {
19+
friendlyName: 'Connection',
20+
description: 'An active database connection.',
21+
extendedDescription: 'The provided database connection instance must still be active. Only database connection instances created by the `getConnection()` machine in this driver are supported.',
22+
example: '===',
23+
required: true
24+
}
2625

2726
},
2827

@@ -38,22 +37,22 @@ module.exports = require('machine').build({
3837
},
3938

4039

41-
fn: function (inputs, exits) {
42-
var util = require('util');
40+
fn: function validateConnection(inputs, exits) {
41+
var _ = require('lodash');
4342

4443
// Validate some basic assertions about the provided connection.
4544
// (this doesn't guarantee it's still active or anything, but it does let
4645
// us know that it at least _HAS_ the properly formatted methods and properties
4746
// necessary for internal use in this Waterline driver)
4847
return exits.success(
49-
util.isObject(inputs.connection) &&
50-
util.isFunction(inputs.connection.query) &&
51-
util.isFunction(inputs.connection.destroy) &&
48+
_.isObject(inputs.connection) &&
49+
_.isFunction(inputs.connection.query) &&
50+
_.isFunction(inputs.connection.destroy) &&
5251
(
5352
// • If you are pooling: `.release()`
54-
util.isFunction(inputs.connection.release) ||
53+
_.isFunction(inputs.connection.release) ||
5554
// • AND/OR if you are not pooling: `.end()`
56-
util.isFunction(inputs.connection.end)
55+
_.isFunction(inputs.connection.end)
5756
)
5857
);
5958
}

0 commit comments

Comments
 (0)