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
- */
7
1
module . exports = require ( 'machine' ) . build ( {
8
2
9
3
@@ -21,8 +15,13 @@ module.exports = require('machine').build({
21
15
22
16
inputs : {
23
17
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
+ }
26
25
27
26
} ,
28
27
@@ -38,22 +37,22 @@ module.exports = require('machine').build({
38
37
} ,
39
38
40
39
41
- fn : function ( inputs , exits ) {
42
- var util = require ( 'util ' ) ;
40
+ fn : function validateConnection ( inputs , exits ) {
41
+ var _ = require ( 'lodash ' ) ;
43
42
44
43
// Validate some basic assertions about the provided connection.
45
44
// (this doesn't guarantee it's still active or anything, but it does let
46
45
// us know that it at least _HAS_ the properly formatted methods and properties
47
46
// necessary for internal use in this Waterline driver)
48
47
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 ) &&
52
51
(
53
52
// • If you are pooling: `.release()`
54
- util . isFunction ( inputs . connection . release ) ||
53
+ _ . isFunction ( inputs . connection . release ) ||
55
54
// • AND/OR if you are not pooling: `.end()`
56
- util . isFunction ( inputs . connection . end )
55
+ _ . isFunction ( inputs . connection . end )
57
56
)
58
57
) ;
59
58
}
0 commit comments