Skip to content

Commit 17c6b1d

Browse files
Merge pull request sailshq#4 from treelinehq/perf
Performance Enchancements
2 parents 09c76d8 + fd86cbe commit 17c6b1d

12 files changed

+132
-100
lines changed

machines/begin-transaction.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ module.exports = {
3737
extendedDescription: 'Until it is committed, rolled back, or times out, subsequent queries run on this connection will be transactional. They will not have any true effect on the database until the transaction is committed, and will not affect queries made on other connections.',
3838
outputVariableName: 'report',
3939
outputDescription: 'The `meta` property is reserved for custom driver-specific extensions.',
40-
example: {
41-
meta: '==='
42-
}
40+
example: '==='
41+
// example: {
42+
// meta: '==='
43+
// }
4344
},
4445

4546
badConnection: {
@@ -48,9 +49,10 @@ module.exports = {
4849
extendedDescription: 'Usually, this means the connection to the database was lost due to a logic error or timing issue in userland code. In production, this can mean that the database became overwhelemed or was shut off while some business logic was in progress.',
4950
outputVariableName: 'report',
5051
outputDescription: 'The `meta` property is reserved for custom driver-specific extensions.',
51-
example: {
52-
meta: '==='
53-
}
52+
example: '==='
53+
// example: {
54+
// meta: '==='
55+
// }
5456
}
5557

5658
},

machines/commit-transaction.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ module.exports = {
4040
extendedDescription: 'Subsequent queries on this connection will no longer be transactional unless a new transaction is begun.',
4141
outputVariableName: 'report',
4242
outputDescription: 'The `meta` property is reserved for custom driver-specific extensions.',
43-
example: {
44-
meta: '==='
45-
}
43+
example: '==='
44+
// example: {
45+
// meta: '==='
46+
// }
4647
},
4748

4849
badConnection: {
@@ -51,9 +52,10 @@ module.exports = {
5152
extendedDescription: 'Usually, this means the connection to the database was lost due to a logic error or timing issue in userland code. In production, this can mean that the database became overwhelemed or was shut off while some business logic was in progress.',
5253
outputVariableName: 'report',
5354
outputDescription: 'The `meta` property is reserved for custom driver-specific extensions.',
54-
example: {
55-
meta: '==='
56-
}
55+
example: '==='
56+
// example: {
57+
// meta: '==='
58+
// }
5759
}
5860

5961
},

machines/compile-statement.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ module.exports = {
2525
description: 'A Waterline statement.',
2626
extendedDescription: 'See documentation for more information. Note that `opts` may be used for expressing driver-specific customizations as a sibling to `from`, `where`, `select`, etc. In other words, recursively deep within a Waterline query statement. This is distinct from `meta`, which contains driver-specific customizations about the statement as a whole.',
2727
moreInfoUrl: 'https://github.com/particlebanana/waterline-query-builder/blob/master/docs/syntax.md',
28-
example: {},
28+
example: '===',
29+
// example: {},
2930
required: true
3031
},
3132

@@ -45,31 +46,34 @@ module.exports = {
4546
description: 'The provided Waterline statement was compiled successfully.',
4647
outputVariableName: 'report',
4748
outputDescription: 'The `nativeQuery` property is the compiled native query for the database. The `meta` property is reserved for custom driver-specific extensions.',
48-
example: {
49-
nativeQuery: '*',
50-
meta: '==='
51-
}
49+
example: '==='
50+
// example: {
51+
// nativeQuery: '*',
52+
// meta: '==='
53+
// }
5254
},
5355

5456
malformed: {
5557
description: 'The provided Waterline statement could not be compiled due to malformed syntax.',
5658
outputVariableName: 'report',
5759
outputDescription: 'The `error` property is a JavaScript error instance explaining that (or preferably even _why_) the Waterline syntax is not valid. The `meta` property is reserved for custom driver-specific extensions.',
58-
example: {
59-
error: '===',
60-
meta: '==='
61-
}
60+
example: '==='
61+
// example: {
62+
// error: '===',
63+
// meta: '==='
64+
// }
6265
},
6366

6467
notSupported: {
6568
description: 'The provided Waterline statement could not be compiled because it is not supported by this MySQL driver.',
6669
extendedDescription: 'If even one clause of the Waterline statement is not supported by the MySQL driver, the compilation of the entire statement _always fails_.',
6770
outputVariableName: 'report',
6871
outputDescription: 'The `error` property is a JavaScript error instance explaining that (or preferably even _why_) the Waterline statement is not supported. The `meta` property is reserved for custom driver-specific extensions.',
69-
example: {
70-
error: '===',
71-
meta: '==='
72-
}
72+
example: '==='
73+
// example: {
74+
// error: '===',
75+
// meta: '==='
76+
// }
7377
}
7478

7579
},

machines/create-manager.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// Dependencies
2+
var util = require('util');
3+
var Url = require('url');
4+
var _ = require('lodash');
5+
var felix = require('mysql');
6+
17
module.exports = {
28

39

@@ -33,7 +39,8 @@ module.exports = {
3339
whereToGet: {
3440
url: 'https://gist.github.com/mikermcneil/46d10fd816c980cd3d9f'
3541
},
36-
example: 'mysql://mikermcneil:p4ssw02D@localhost:3306/some_db',
42+
example: '===',
43+
// example: 'mysql://mikermcneil:p4ssw02D@localhost:3306/some_db',
3744
required: true
3845
},
3946

@@ -75,20 +82,22 @@ module.exports = {
7582
'basis; and it may also vary based on the configuration passed into the `meta` input.',
7683
outputVariableName: 'report',
7784
outputDescription: 'The `manager` property is a manager instance that will be passed into `getConnection()`. The `meta` property is reserved for custom driver-specific extensions.',
78-
example: {
79-
manager: '===',
80-
meta: '==='
81-
}
85+
example: '==='
86+
// example: {
87+
// manager: '===',
88+
// meta: '==='
89+
// }
8290
},
8391

8492
malformed: {
8593
description: 'The provided connection string is not valid for MySQL.',
8694
outputVariableName: 'report',
8795
outputDescription: 'The `error` property is a JavaScript Error instance explaining that (and preferably "why") the provided connection string is invalid. The `meta` property is reserved for custom driver-specific extensions.',
88-
example: {
89-
error: '===',
90-
meta: '==='
91-
}
96+
example: '==='
97+
// example: {
98+
// error: '===',
99+
// meta: '==='
100+
// }
92101
},
93102

94103
failed: {
@@ -110,22 +119,17 @@ module.exports = {
110119
'any errors related to bad credentials, connectivity, etc. will not be caught until `getConnection()` is called.',
111120
outputVariableName: 'report',
112121
outputDescription: 'The `error` property is a JavaScript Error instance with more information and a stack trace. The `meta` property is reserved for custom driver-specific extensions.',
113-
example: {
114-
error: '===',
115-
meta: '==='
116-
}
122+
example: '==='
123+
// example: {
124+
// error: '===',
125+
// meta: '==='
126+
// }
117127
}
118128

119129
},
120130

121131

122132
fn: function createManager(inputs, exits) {
123-
var util = require('util');
124-
var Url = require('url');
125-
var _ = require('lodash');
126-
var felix = require('mysql');
127-
128-
129133
// Note:
130134
// Support for different types of managers is database-specific, and is not
131135
// built into the Waterline driver spec-- however this type of configurability

machines/destroy-manager.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ module.exports = {
3333
description: 'The specified manager and all of its active connections were successfully destroyed.',
3434
outputVariableName: 'report',
3535
outputDescription: 'The `meta` property is reserved for custom driver-specific extensions.',
36-
example: {
37-
meta: '==='
38-
}
36+
example: '==='
37+
// example: {
38+
// meta: '==='
39+
// }
3940
},
4041

4142
failed: {
@@ -47,10 +48,11 @@ module.exports = {
4748
'server(s) became overwhelemed or were shut off while some business logic was in progress.',
4849
outputVariableName: 'report',
4950
outputDescription: 'The `error` property is a JavaScript Error instance with more information and a stack trace. The `meta` property is reserved for custom driver-specific extensions.',
50-
example: {
51-
error: '===',
52-
meta: '==='
53-
}
51+
example: '==='
52+
// example: {
53+
// error: '===',
54+
// meta: '==='
55+
// }
5456
}
5557

5658
},

machines/get-connection.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ module.exports = {
3939
extendedDescription: 'This connection should be eventually released. Otherwise, it may time out. It is not a good idea to rely on database connections timing out-- be sure to release this connection when finished with it!',
4040
outputVariableName: 'report',
4141
outputDescription: 'The `connection` property is an active connection to the database. The `meta` property is reserved for custom driver-specific extensions.',
42-
example: {
43-
connection: '===',
44-
meta: '==='
45-
}
42+
example: '==='
43+
// example: {
44+
// connection: '===',
45+
// meta: '==='
46+
// }
4647
},
4748

4849
failed: {
@@ -56,10 +57,11 @@ module.exports = {
5657
' + any other miscellaneous connection error',
5758
outputVariableName: 'report',
5859
outputDescription: 'The `error` property is a JavaScript Error instance explaining that a connection could not be made. The `meta` property is reserved for custom driver-specific extensions.',
59-
example: {
60-
error: '===',
61-
meta: '==='
62-
}
60+
example: '==='
61+
// example: {
62+
// error: '===',
63+
// meta: '==='
64+
// }
6365
}
6466

6567
},

machines/parse-native-query-error.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Dependencies
2+
var _ = require('lodash');
3+
14
module.exports = {
25

36

@@ -42,18 +45,17 @@ module.exports = {
4245
moreInfoUrl: 'https://github.com/node-machine/waterline-driver-interface#footprints',
4346
outputVariableName: 'report',
4447
outputDescription: 'The `footprint` property is the normalized "footprint" representing the provided raw error. Conforms to one of a handful of standardized footprint types expected by the Waterline driver interface. The `meta` property is reserved for custom driver-specific extensions.',
45-
example: {
46-
footprint: {},
47-
meta: '==='
48-
}
48+
example: '==='
49+
// example: {
50+
// footprint: {},
51+
// meta: '==='
52+
// }
4953
},
5054

5155
},
5256

5357

5458
fn: function parseNativeQueryError(inputs, exits) {
55-
var _ = require('lodash');
56-
5759
// Quick reference of hand-tested errors:
5860

5961
// --o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o-<>

machines/parse-native-query-result.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Dependencies
2+
var _ = require('lodash');
3+
14
module.exports = {
25

36

@@ -22,7 +25,8 @@ module.exports = {
2225
'Either "select", "insert", "destroy", "update", "count", "sum", or "avg". ' +
2326
'This determines how the provided raw result will be parsed/coerced.',
2427
required: true,
25-
example: 'select'
28+
example: '==='
29+
// example: 'select'
2630
},
2731

2832
nativeQueryResult: {
@@ -48,17 +52,17 @@ module.exports = {
4852
description: 'The result was successfully normalized.',
4953
outputVariableName: 'report',
5054
outputDescription: 'The `result` property is the normalized version of the raw result originally provided. The `meta` property is reserved for custom driver-specific extensions.',
51-
example: {
52-
result: '*',
53-
meta: '==='
54-
}
55+
example: '==='
56+
// example: {
57+
// result: '*',
58+
// meta: '==='
59+
// }
5560
},
5661

5762
},
5863

5964

6065
fn: function parseNativeQueryResult(inputs, exits) {
61-
var _ = require('lodash');
6266
var normalizedResult;
6367

6468
switch (inputs.queryType) {

machines/release-connection.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ module.exports = {
3434
extendedDescription: 'The provided connection may no longer be used for any subsequent queries.',
3535
outputVariableName: 'report',
3636
outputDescription: 'The `meta` property is reserved for custom driver-specific extensions.',
37-
example: {
38-
meta: '==='
39-
}
37+
example: '==='
38+
// example: {
39+
// meta: '==='
40+
// }
4041
},
4142

4243
badConnection: {
@@ -45,9 +46,10 @@ module.exports = {
4546
extendedDescription: 'Usually, this means the connection to the database was lost due to a logic error or timing issue in userland code. In production, this can mean that the database became overwhelemed or was shut off while some business logic was in progress.',
4647
outputVariableName: 'report',
4748
outputDescription: 'The `meta` property is reserved for custom driver-specific extensions.',
48-
example: {
49-
meta: '==='
50-
}
49+
example: '==='
50+
// example: {
51+
// meta: '==='
52+
// }
5153
}
5254

5355
},

machines/rollback-transaction.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,20 @@ module.exports = {
4040
extendedDescription: 'Subsequent queries on this connection will no longer be transactional unless a new transaction is begun.',
4141
outputVariableName: 'report',
4242
outputDescription: 'The `meta` property is reserved for custom driver-specific extensions.',
43-
example: {
44-
meta: '==='
45-
}
43+
example: '==='
44+
// example: {
45+
// meta: '==='
46+
// }
4647
},
4748

4849
badConnection: {
4950
friendlyName: 'Meta (custom)',
5051
description: 'Additional stuff to pass to the driver.',
5152
extendedDescription: 'This is reserved for custom driver-specific extensions. Please refer to the documentation for the driver you are using for more specific information.',
52-
example: {
53-
meta: '==='
54-
}
53+
example: '==='
54+
// example: {
55+
// meta: '==='
56+
// }
5557
}
5658

5759
},

0 commit comments

Comments
 (0)