pg-promise 11.4.0 → 11.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +42 -42
  2. package/lib/assert.js +1 -1
  3. package/lib/connect.js +17 -17
  4. package/lib/database-pool.js +5 -5
  5. package/lib/database.js +37 -37
  6. package/lib/errors/index.js +4 -4
  7. package/lib/errors/parameterized-query-error.js +12 -12
  8. package/lib/errors/prepared-statement-error.js +13 -13
  9. package/lib/errors/query-file-error.js +10 -10
  10. package/lib/errors/query-result-error.js +13 -13
  11. package/lib/events.js +17 -17
  12. package/lib/formatting.js +69 -69
  13. package/lib/helpers/column-set.js +29 -29
  14. package/lib/helpers/column.js +39 -39
  15. package/lib/helpers/index.js +4 -4
  16. package/lib/helpers/methods/concat.js +9 -9
  17. package/lib/helpers/methods/index.js +5 -5
  18. package/lib/helpers/methods/insert.js +15 -15
  19. package/lib/helpers/methods/sets.js +5 -5
  20. package/lib/helpers/methods/update.js +22 -22
  21. package/lib/helpers/methods/values.js +10 -10
  22. package/lib/helpers/table-name.js +7 -7
  23. package/lib/index.js +3 -3
  24. package/lib/inner-state.js +3 -3
  25. package/lib/main.js +32 -32
  26. package/lib/patterns.js +1 -1
  27. package/lib/promise-adapter.js +12 -12
  28. package/lib/promise-parser.js +7 -7
  29. package/lib/query-file.js +21 -21
  30. package/lib/query.js +19 -19
  31. package/lib/stream.js +11 -11
  32. package/lib/task.js +25 -25
  33. package/lib/text.js +17 -17
  34. package/lib/tx-mode.js +14 -14
  35. package/lib/types/index.js +3 -3
  36. package/lib/types/parameterized-query.js +16 -16
  37. package/lib/types/prepared-statement.js +18 -18
  38. package/lib/types/server-formatting.js +3 -3
  39. package/lib/utils/color.js +1 -1
  40. package/lib/utils/index.js +20 -20
  41. package/lib/utils/public.js +26 -26
  42. package/package.json +5 -5
  43. package/typescript/pg-subset.d.ts +1 -1
@@ -7,11 +7,11 @@
7
7
  * Removal or modification of this copyright notice is prohibited.
8
8
  */
9
9
 
10
- const {assert} = require(`../assert`);
10
+ const {assert} = require('../assert');
11
11
 
12
12
  const npm = {
13
- utils: require(`../utils`),
14
- format: require(`../formatting`).as // formatting namespace
13
+ utils: require('../utils'),
14
+ format: require('../formatting').as // formatting namespace
15
15
  };
16
16
 
17
17
  /**
@@ -62,21 +62,21 @@ const npm = {
62
62
  class TableName {
63
63
 
64
64
  constructor(table) {
65
- if (typeof table === `string`) {
65
+ if (typeof table === 'string') {
66
66
  this.table = table;
67
67
  } else {
68
- const config = assert(table, [`table`, `schema`]);
68
+ const config = assert(table, ['table', 'schema']);
69
69
  this.table = config.table;
70
70
  if (npm.utils.isText(config.schema)) {
71
71
  this.schema = config.schema;
72
72
  }
73
73
  }
74
74
  if (!npm.utils.isText(this.table)) {
75
- throw new TypeError(`Table name must be a non-empty text string.`);
75
+ throw new TypeError('Table name must be a non-empty text string.');
76
76
  }
77
77
  this.name = npm.format.name(this.table);
78
78
  if (this.schema) {
79
- this.name = npm.format.name(this.schema) + `.` + this.name;
79
+ this.name = npm.format.name(this.schema) + '.' + this.name;
80
80
  }
81
81
  Object.freeze(this);
82
82
  }
package/lib/index.js CHANGED
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  /* eslint no-var: off */
11
- var v = process.versions.node.split(`.`),
11
+ var v = process.versions.node.split('.'),
12
12
  highVer = +v[0];
13
13
 
14
14
  // istanbul ignore next
@@ -22,7 +22,7 @@ if (highVer < 14) {
22
22
  // Node.js v4.5.0 was supported up to pg-promise v8.7.5
23
23
  // Node.js v0.10 was supported up to pg-promise v5.5.8
24
24
 
25
- throw new Error(`Minimum Node.js version supported by pg-promise is 14.0.0`);
25
+ throw new Error('Minimum Node.js version supported by pg-promise is 14.0.0');
26
26
  }
27
27
 
28
- module.exports = require(`./main`);
28
+ module.exports = require('./main');
@@ -1,4 +1,4 @@
1
- const {addReadProp} = require(`./utils`);
1
+ const {addReadProp} = require('./utils');
2
2
 
3
3
  /**
4
4
  * @private
@@ -10,8 +10,8 @@ const {addReadProp} = require(`./utils`);
10
10
  class InnerState {
11
11
 
12
12
  constructor(initialState) {
13
- addReadProp(this, `_inner`, {}, true);
14
- if (initialState && typeof initialState === `object`) {
13
+ addReadProp(this, '_inner', {}, true);
14
+ if (initialState && typeof initialState === 'object') {
15
15
  this.extendState(initialState);
16
16
  }
17
17
  }
package/lib/main.js CHANGED
@@ -7,26 +7,26 @@
7
7
  * Removal or modification of this copyright notice is prohibited.
8
8
  */
9
9
 
10
- const {PromiseAdapter} = require(`./promise-adapter`);
11
- const {DatabasePool} = require(`./database-pool`);
12
- const {PreparedStatement, ParameterizedQuery} = require(`./types`);
13
- const {QueryFile} = require(`./query-file`);
14
- const {queryResult} = require(`./query-result`);
15
- const {parsePromise} = require(`./promise-parser`);
16
- const {assert} = require(`./assert`);
10
+ const {PromiseAdapter} = require('./promise-adapter');
11
+ const {DatabasePool} = require('./database-pool');
12
+ const {PreparedStatement, ParameterizedQuery} = require('./types');
13
+ const {QueryFile} = require('./query-file');
14
+ const {queryResult} = require('./query-result');
15
+ const {parsePromise} = require('./promise-parser');
16
+ const {assert} = require('./assert');
17
17
 
18
18
  const npm = {
19
- path: require(`path`),
20
- pg: require(`pg`),
21
- minify: require(`pg-minify`),
22
- formatting: require(`./formatting`),
23
- helpers: require(`./helpers`),
24
- errors: require(`./errors`),
25
- utils: require(`./utils`),
26
- pubUtils: require(`./utils/public`),
27
- mode: require(`./tx-mode`),
28
- package: require(`../package.json`),
29
- text: require(`./text`)
19
+ path: require('path'),
20
+ pg: require('pg'),
21
+ minify: require('pg-minify'),
22
+ formatting: require('./formatting'),
23
+ helpers: require('./helpers'),
24
+ errors: require('./errors'),
25
+ utils: require('./utils'),
26
+ pubUtils: require('./utils/public'),
27
+ mode: require('./tx-mode'),
28
+ package: require('../package.json'),
29
+ text: require('./text')
30
30
  };
31
31
 
32
32
  let originalClientConnect;
@@ -178,8 +178,8 @@ let originalClientConnect;
178
178
  */
179
179
  function $main(options) {
180
180
 
181
- options = assert(options, [`pgFormatting`, `pgNative`, `promiseLib`, `capSQL`, `noWarnings`,
182
- `connect`, `disconnect`, `query`, `receive`, `task`, `transact`, `error`, `extend`, `schema`]);
181
+ options = assert(options, ['pgFormatting', 'pgNative', 'promiseLib', 'capSQL', 'noWarnings',
182
+ 'connect', 'disconnect', 'query', 'receive', 'task', 'transact', 'error', 'extend', 'schema']);
183
183
 
184
184
  let pg = npm.pg;
185
185
  const p = parsePromise(options.promiseLib);
@@ -190,11 +190,11 @@ function $main(options) {
190
190
  promise: p.promise
191
191
  };
192
192
 
193
- npm.utils.addReadProp(config, `$npm`, {}, true);
193
+ npm.utils.addReadProp(config, '$npm', {}, true);
194
194
 
195
195
  // Locking properties that cannot be changed later:
196
- npm.utils.addReadProp(options, `promiseLib`, options.promiseLib);
197
- npm.utils.addReadProp(options, `pgNative`, !!options.pgNative);
196
+ npm.utils.addReadProp(options, 'promiseLib', options.promiseLib);
197
+ npm.utils.addReadProp(options, 'pgNative', !!options.pgNative);
198
198
 
199
199
  config.options = options;
200
200
 
@@ -210,24 +210,24 @@ function $main(options) {
210
210
  originalClientConnect = pg.Client.prototype.connect;
211
211
  pg.Client.prototype.connect = function () {
212
212
  const handler = msg => {
213
- if (msg.parameterName === `server_version`) {
213
+ if (msg.parameterName === 'server_version') {
214
214
  this.serverVersion = msg.parameterValue;
215
- this.connection.removeListener(`parameterStatus`, handler);
215
+ this.connection.removeListener('parameterStatus', handler);
216
216
  }
217
217
  };
218
- this.connection.on(`parameterStatus`, handler);
218
+ this.connection.on('parameterStatus', handler);
219
219
  return originalClientConnect.call(this, ...arguments);
220
220
  };
221
221
  }
222
222
  }
223
223
 
224
- const Database = require(`./database`)(config);
224
+ const Database = require('./database')(config);
225
225
 
226
226
  const inst = (cn, dc) => {
227
- if (npm.utils.isText(cn) || (cn && typeof cn === `object`)) {
227
+ if (npm.utils.isText(cn) || (cn && typeof cn === 'object')) {
228
228
  return new Database(cn, dc, config);
229
229
  }
230
- throw new TypeError(`Invalid connection details: ` + npm.utils.toJson(cn));
230
+ throw new TypeError('Invalid connection details: ' + npm.utils.toJson(cn));
231
231
  };
232
232
 
233
233
  npm.utils.addReadProperties(inst, rootNameSpace);
@@ -258,7 +258,7 @@ function $main(options) {
258
258
  *
259
259
  * For more details see $[Library de-initialization].
260
260
  */
261
- npm.utils.addReadProp(inst, `end`, () => {
261
+ npm.utils.addReadProp(inst, 'end', () => {
262
262
  DatabasePool.shutDown();
263
263
  });
264
264
 
@@ -272,7 +272,7 @@ function $main(options) {
272
272
  *
273
273
  * @see {@link helpers}.
274
274
  */
275
- npm.utils.addReadProp(inst, `helpers`, npm.helpers(config));
275
+ npm.utils.addReadProp(inst, 'helpers', npm.helpers(config));
276
276
 
277
277
  /**
278
278
  * @member {external:spex} spex
@@ -287,7 +287,7 @@ function $main(options) {
287
287
  * {@link Task#page},
288
288
  * {@link Task#sequence}
289
289
  */
290
- npm.utils.addReadProp(inst, `spex`, config.$npm.spex);
290
+ npm.utils.addReadProp(inst, 'spex', config.$npm.spex);
291
291
 
292
292
  config.pgp = inst;
293
293
 
package/lib/patterns.js CHANGED
@@ -39,5 +39,5 @@ module.exports = {
39
39
  hasValidModifier: /\^|~|#|:raw|:alias|:name|:json|:csv|:list|:value/,
40
40
 
41
41
  // List of all supported formatting modifiers:
42
- validModifiers: [`^`, `~`, `#`, `:raw`, `:alias`, `:name`, `:json`, `:csv`, `:list`, `:value`]
42
+ validModifiers: ['^', '~', '#', ':raw', ':alias', ':name', ':json', ':csv', ':list', ':value']
43
43
  };
@@ -7,7 +7,7 @@
7
7
  * Removal or modification of this copyright notice is prohibited.
8
8
  */
9
9
 
10
- const {assert} = require(`./assert`);
10
+ const {assert} = require('./assert');
11
11
 
12
12
  /**
13
13
  * @class PromiseAdapter
@@ -54,31 +54,31 @@ const {assert} = require(`./assert`);
54
54
  class PromiseAdapter {
55
55
  constructor(api) {
56
56
 
57
- if (!api || typeof api !== `object`) {
58
- throw new TypeError(`Adapter requires an api configuration object.`);
57
+ if (!api || typeof api !== 'object') {
58
+ throw new TypeError('Adapter requires an api configuration object.');
59
59
  }
60
60
 
61
- api = assert(api, [`create`, `resolve`, `reject`, `all`]);
61
+ api = assert(api, ['create', 'resolve', 'reject', 'all']);
62
62
 
63
63
  this.create = api.create;
64
64
  this.resolve = api.resolve;
65
65
  this.reject = api.reject;
66
66
  this.all = api.all;
67
67
 
68
- if (typeof this.create !== `function`) {
69
- throw new TypeError(`Function 'create' must be specified.`);
68
+ if (typeof this.create !== 'function') {
69
+ throw new TypeError('Function \'create\' must be specified.');
70
70
  }
71
71
 
72
- if (typeof this.resolve !== `function`) {
73
- throw new TypeError(`Function 'resolve' must be specified.`);
72
+ if (typeof this.resolve !== 'function') {
73
+ throw new TypeError('Function \'resolve\' must be specified.');
74
74
  }
75
75
 
76
- if (typeof this.reject !== `function`) {
77
- throw new TypeError(`Function 'reject' must be specified.`);
76
+ if (typeof this.reject !== 'function') {
77
+ throw new TypeError('Function \'reject\' must be specified.');
78
78
  }
79
79
 
80
- if (typeof this.all !== `function`) {
81
- throw new TypeError(`Function 'all' must be specified.`);
80
+ if (typeof this.all !== 'function') {
81
+ throw new TypeError('Function \'all\' must be specified.');
82
82
  }
83
83
  }
84
84
  }
@@ -7,7 +7,7 @@
7
7
  * Removal or modification of this copyright notice is prohibited.
8
8
  */
9
9
 
10
- const {PromiseAdapter} = require(`./promise-adapter`);
10
+ const {PromiseAdapter} = require('./promise-adapter');
11
11
 
12
12
  //////////////////////////////////////////
13
13
  // Parses and validates a promise library;
@@ -24,22 +24,22 @@ function parse(pl) {
24
24
  return promise;
25
25
  }
26
26
  const t = typeof pl;
27
- if (t === `function` || t === `object`) {
28
- const Root = typeof pl.Promise === `function` ? pl.Promise : pl;
27
+ if (t === 'function' || t === 'object') {
28
+ const Root = typeof pl.Promise === 'function' ? pl.Promise : pl;
29
29
  promise = function (func) {
30
30
  return new Root(func);
31
31
  };
32
32
  promise.resolve = Root.resolve;
33
33
  promise.reject = Root.reject;
34
34
  promise.all = Root.all;
35
- if (typeof promise.resolve === `function` &&
36
- typeof promise.reject === `function` &&
37
- typeof promise.all === `function`) {
35
+ if (typeof promise.resolve === 'function' &&
36
+ typeof promise.reject === 'function' &&
37
+ typeof promise.all === 'function') {
38
38
  return promise;
39
39
  }
40
40
  }
41
41
 
42
- throw new TypeError(`Invalid promise library specified.`);
42
+ throw new TypeError('Invalid promise library specified.');
43
43
  }
44
44
 
45
45
  function parsePromise(promiseLib) {
package/lib/query-file.js CHANGED
@@ -7,21 +7,21 @@
7
7
  * Removal or modification of this copyright notice is prohibited.
8
8
  */
9
9
 
10
- const {InnerState} = require(`./inner-state`);
11
- const {QueryFileError} = require(`./errors`);
12
- const {assert} = require(`./assert`);
13
- const {ColorConsole} = require(`./utils/color`);
10
+ const {InnerState} = require('./inner-state');
11
+ const {QueryFileError} = require('./errors');
12
+ const {assert} = require('./assert');
13
+ const {ColorConsole} = require('./utils/color');
14
14
 
15
15
  const npm = {
16
- fs: require(`fs`),
17
- os: require(`os`),
18
- path: require(`path`),
19
- minify: require(`pg-minify`),
20
- utils: require(`./utils`),
21
- formatting: require(`./formatting`)
16
+ fs: require('fs'),
17
+ os: require('os'),
18
+ path: require('path'),
19
+ minify: require('pg-minify'),
20
+ utils: require('./utils'),
21
+ formatting: require('./formatting')
22
22
  };
23
23
 
24
- const file$query = Symbol(`QueryFile.query`);
24
+ const file$query = Symbol('QueryFile.query');
25
25
 
26
26
  /**
27
27
  * @class QueryFile
@@ -151,7 +151,7 @@ class QueryFile extends InnerState {
151
151
  * @return {{usedPath: {}}}
152
152
  */
153
153
  static get instance() {
154
- const s = Symbol.for(`pgPromiseQueryFile`);
154
+ const s = Symbol.for('pgPromiseQueryFile');
155
155
  let scope = global[s];
156
156
  if (!scope) {
157
157
  scope = {
@@ -253,15 +253,15 @@ class QueryFile extends InnerState {
253
253
  return;
254
254
  }
255
255
  try {
256
- i.sql = npm.fs.readFileSync(i.filePath, `utf8`);
256
+ i.sql = npm.fs.readFileSync(i.filePath, 'utf8');
257
257
  i.modTime = lastMod || npm.fs.statSync(i.filePath).mtime.getTime();
258
- if (options.minify && options.minify !== `after`) {
258
+ if (options.minify && options.minify !== 'after') {
259
259
  i.sql = npm.minify(i.sql, {compress: options.compress});
260
260
  }
261
261
  if (options.params !== undefined) {
262
262
  i.sql = npm.formatting.as.format(i.sql, options.params, {partial: true});
263
263
  }
264
- if (options.minify && options.minify === `after`) {
264
+ if (options.minify && options.minify === 'after') {
265
265
  i.sql = npm.minify(i.sql, {compress: options.compress});
266
266
  }
267
267
  i.ready = true;
@@ -328,17 +328,17 @@ QueryFile.prototype.toString = function (level) {
328
328
  level = level > 0 ? parseInt(level) : 0;
329
329
  const gap = npm.utils.messageGap(level + 1);
330
330
  const lines = [
331
- `QueryFile {`
331
+ 'QueryFile {'
332
332
  ];
333
333
  this.prepare();
334
- lines.push(gap + `file: "` + this.file + `"`);
335
- lines.push(gap + `options: ` + npm.utils.toJson(this.options));
334
+ lines.push(gap + 'file: "' + this.file + '"');
335
+ lines.push(gap + 'options: ' + npm.utils.toJson(this.options));
336
336
  if (this.error) {
337
- lines.push(gap + `error: ` + this.error.toString(level + 1));
337
+ lines.push(gap + 'error: ' + this.error.toString(level + 1));
338
338
  } else {
339
- lines.push(gap + `query: "` + this[QueryFile.$query] + `"`);
339
+ lines.push(gap + 'query: "' + this[QueryFile.$query] + '"');
340
340
  }
341
- lines.push(npm.utils.messageGap(level) + `}`);
341
+ lines.push(npm.utils.messageGap(level) + '}');
342
342
  return lines.join(npm.os.EOL);
343
343
  };
344
344
 
package/lib/query.js CHANGED
@@ -7,19 +7,19 @@
7
7
  * Removal or modification of this copyright notice is prohibited.
8
8
  */
9
9
 
10
- const {Events} = require(`./events`);
11
- const {QueryFile} = require(`./query-file`);
12
- const {ServerFormatting, PreparedStatement, ParameterizedQuery} = require(`./types`);
13
- const {SpecialQuery} = require(`./special-query`);
14
- const {queryResult} = require(`./query-result`);
10
+ const {Events} = require('./events');
11
+ const {QueryFile} = require('./query-file');
12
+ const {ServerFormatting, PreparedStatement, ParameterizedQuery} = require('./types');
13
+ const {SpecialQuery} = require('./special-query');
14
+ const {queryResult} = require('./query-result');
15
15
 
16
16
  const npm = {
17
- util: require(`util`),
18
- utils: require(`./utils`),
19
- formatting: require(`./formatting`),
20
- errors: require(`./errors`),
21
- stream: require(`./stream`),
22
- text: require(`./text`)
17
+ util: require('util'),
18
+ utils: require('./utils'),
19
+ formatting: require('./formatting'),
20
+ errors: require('./errors'),
21
+ stream: require('./stream'),
22
+ text: require('./text')
23
23
  };
24
24
 
25
25
  const QueryResultError = npm.errors.QueryResultError,
@@ -46,7 +46,7 @@ function $query(ctx, query, values, qrm, config) {
46
46
  pgFormatting = opt.pgFormatting,
47
47
  params = pgFormatting ? values : undefined;
48
48
 
49
- if (typeof query === `function`) {
49
+ if (typeof query === 'function') {
50
50
  try {
51
51
  query = npm.formatting.resolveFunc(query, values);
52
52
  } catch (e) {
@@ -60,7 +60,7 @@ function $query(ctx, query, values, qrm, config) {
60
60
  error = new TypeError(npm.text.invalidQuery);
61
61
  }
62
62
 
63
- if (!error && typeof query === `object`) {
63
+ if (!error && typeof query === 'object') {
64
64
  if (query instanceof QueryFile) {
65
65
  query.prepare();
66
66
  if (query.error) {
@@ -70,18 +70,18 @@ function $query(ctx, query, values, qrm, config) {
70
70
  query = query[QueryFile.$query];
71
71
  }
72
72
  } else {
73
- if (`entity` in query) {
73
+ if ('entity' in query) {
74
74
  entityType = query.type;
75
75
  query = query.entity; // query is a function name;
76
76
  } else {
77
77
  if (query instanceof ServerFormatting) {
78
78
  pgFormatting = true;
79
79
  } else {
80
- if (`name` in query) {
80
+ if ('name' in query) {
81
81
  query = new PreparedStatement(query);
82
82
  pgFormatting = true;
83
83
  } else {
84
- if (`text` in query) {
84
+ if ('text' in query) {
85
85
  query = new ParameterizedQuery(query);
86
86
  pgFormatting = true;
87
87
  }
@@ -96,7 +96,7 @@ function $query(ctx, query, values, qrm, config) {
96
96
 
97
97
  if (!error) {
98
98
  if (!pgFormatting && !npm.utils.isText(query)) {
99
- const errTxt = entityType ? (entityType === `func` ? npm.text.invalidFunction : npm.text.invalidProc) : npm.text.invalidQuery;
99
+ const errTxt = entityType ? (entityType === 'func' ? npm.text.invalidFunction : npm.text.invalidProc) : npm.text.invalidQuery;
100
100
  error = new TypeError(errTxt);
101
101
  }
102
102
  if (query instanceof ServerFormatting) {
@@ -130,11 +130,11 @@ function $query(ctx, query, values, qrm, config) {
130
130
  }
131
131
  } catch (e) {
132
132
  if (entityType) {
133
- let prefix = entityType === `func` ? `select * from` : `call`;
133
+ let prefix = entityType === 'func' ? 'select * from' : 'call';
134
134
  if (capSQL) {
135
135
  prefix = prefix.toUpperCase();
136
136
  }
137
- query = prefix + ` ` + query + `(...)`;
137
+ query = prefix + ' ' + query + '(...)';
138
138
  } else {
139
139
  params = values;
140
140
  }
package/lib/stream.js CHANGED
@@ -7,11 +7,11 @@
7
7
  * Removal or modification of this copyright notice is prohibited.
8
8
  */
9
9
 
10
- const {Events} = require(`./events`);
10
+ const {Events} = require('./events');
11
11
 
12
12
  const npm = {
13
- utils: require(`./utils`),
14
- text: require(`./text`)
13
+ utils: require('./utils'),
14
+ text: require('./text')
15
15
  };
16
16
 
17
17
  ////////////////////////////////////////////
@@ -28,7 +28,7 @@ function $stream(ctx, qs, initCB, config) {
28
28
  }
29
29
  // Stream class was renamed again, see the following issue:
30
30
  // https://github.com/brianc/node-postgres/issues/2412
31
- if (!qs || !qs.constructor || qs.constructor.name !== `QueryStream`) {
31
+ if (!qs || !qs.constructor || qs.constructor.name !== 'QueryStream') {
32
32
  // invalid or missing stream object;
33
33
  return $p.reject(new TypeError(npm.text.invalidStream));
34
34
  }
@@ -36,7 +36,7 @@ function $stream(ctx, qs, initCB, config) {
36
36
  // stream object is in the wrong state;
37
37
  return $p.reject(new Error(npm.text.invalidStreamState));
38
38
  }
39
- if (typeof initCB !== `function`) {
39
+ if (typeof initCB !== 'function') {
40
40
  // parameter `initCB` must be passed as the initialization callback;
41
41
  return $p.reject(new TypeError(npm.text.invalidStreamCB));
42
42
  }
@@ -51,9 +51,9 @@ function $stream(ctx, qs, initCB, config) {
51
51
 
52
52
  const stream = ctx.db.client.query(qs);
53
53
 
54
- stream.on(`data`, onData);
55
- stream.on(`error`, onError);
56
- stream.on(`end`, onEnd);
54
+ stream.on('data', onData);
55
+ stream.on('error', onError);
56
+ stream.on('end', onEnd);
57
57
 
58
58
  try {
59
59
  initCB.call(this, stream); // the stream must be initialized during the call;
@@ -92,9 +92,9 @@ function $stream(ctx, qs, initCB, config) {
92
92
  }
93
93
 
94
94
  function release() {
95
- stream.removeListener(`data`, onData);
96
- stream.removeListener(`error`, onError);
97
- stream.removeListener(`end`, onEnd);
95
+ stream.removeListener('data', onData);
96
+ stream.removeListener('error', onError);
97
+ stream.removeListener('end', onEnd);
98
98
  }
99
99
 
100
100
  function getError(e) {
package/lib/task.js CHANGED
@@ -7,14 +7,14 @@
7
7
  * Removal or modification of this copyright notice is prohibited.
8
8
  */
9
9
 
10
- const {Events} = require(`./events`);
10
+ const {Events} = require('./events');
11
11
 
12
12
  const npm = {
13
- spex: require(`spex`),
14
- utils: require(`./utils`),
15
- mode: require(`./tx-mode`),
16
- query: require(`./query`),
17
- text: require(`./text`)
13
+ spex: require('spex'),
14
+ utils: require('./utils'),
15
+ mode: require('./tx-mode'),
16
+ query: require('./query'),
17
+ text: require('./text')
18
18
  };
19
19
 
20
20
  /**
@@ -91,23 +91,23 @@ function Task(ctx, tag, isTX, config) {
91
91
  */
92
92
  this.ctx = ctx.ctx = {}; // task context object;
93
93
 
94
- npm.utils.addReadProp(this.ctx, `isTX`, isTX);
94
+ npm.utils.addReadProp(this.ctx, 'isTX', isTX);
95
95
 
96
- if (`context` in ctx) {
97
- npm.utils.addReadProp(this.ctx, `context`, ctx.context);
96
+ if ('context' in ctx) {
97
+ npm.utils.addReadProp(this.ctx, 'context', ctx.context);
98
98
  }
99
99
 
100
- npm.utils.addReadProp(this.ctx, `connected`, !ctx.db);
101
- npm.utils.addReadProp(this.ctx, `tag`, tag);
102
- npm.utils.addReadProp(this.ctx, `dc`, ctx.dc);
103
- npm.utils.addReadProp(this.ctx, `level`, ctx.level);
104
- npm.utils.addReadProp(this.ctx, `inTransaction`, ctx.inTransaction);
100
+ npm.utils.addReadProp(this.ctx, 'connected', !ctx.db);
101
+ npm.utils.addReadProp(this.ctx, 'tag', tag);
102
+ npm.utils.addReadProp(this.ctx, 'dc', ctx.dc);
103
+ npm.utils.addReadProp(this.ctx, 'level', ctx.level);
104
+ npm.utils.addReadProp(this.ctx, 'inTransaction', ctx.inTransaction);
105
105
 
106
106
  if (isTX) {
107
- npm.utils.addReadProp(this.ctx, `txLevel`, ctx.txLevel);
107
+ npm.utils.addReadProp(this.ctx, 'txLevel', ctx.txLevel);
108
108
  }
109
109
 
110
- npm.utils.addReadProp(this.ctx, `parent`, ctx.parentCtx);
110
+ npm.utils.addReadProp(this.ctx, 'parent', ctx.parentCtx);
111
111
 
112
112
  // generic query method;
113
113
  this.query = function (query, values, qrm) {
@@ -193,10 +193,10 @@ const callback = (ctx, obj, cb, config) => {
193
193
  let result;
194
194
 
195
195
  try {
196
- if (cb.constructor.name === `GeneratorFunction`) {
196
+ if (cb.constructor.name === 'GeneratorFunction') {
197
197
  // v9.0 dropped all support for ES6 generator functions;
198
198
  // Clients should use the new ES7 async/await syntax.
199
- throw new TypeError(`ES6 generator functions are no longer supported!`);
199
+ throw new TypeError('ES6 generator functions are no longer supported!');
200
200
  }
201
201
  result = cb.call(obj, obj); // invoking the callback function;
202
202
  } catch (err) {
@@ -207,7 +207,7 @@ const callback = (ctx, obj, cb, config) => {
207
207
  });
208
208
  return $p.reject(err); // reject with the error;
209
209
  }
210
- if (result && typeof result.then === `function`) {
210
+ if (result && typeof result.then === 'function') {
211
211
  return result; // result is a valid promise object;
212
212
  }
213
213
  return $p.resolve(result);
@@ -232,7 +232,7 @@ const execute = (ctx, obj, isTX, config) => {
232
232
  function update(start, success, result) {
233
233
  const c = ctx.ctx;
234
234
  if (start) {
235
- npm.utils.addReadProp(c, `start`, new Date());
235
+ npm.utils.addReadProp(c, 'start', new Date());
236
236
  } else {
237
237
  c.finish = new Date();
238
238
  c.success = success;
@@ -294,22 +294,22 @@ const execute = (ctx, obj, isTX, config) => {
294
294
 
295
295
  function begin() {
296
296
  if (!ctx.txLevel && ctx.mode instanceof npm.mode.TransactionMode) {
297
- return exec(ctx.mode.begin(capSQL), `savepoint`);
297
+ return exec(ctx.mode.begin(capSQL), 'savepoint');
298
298
  }
299
- return exec(`begin`, `savepoint`);
299
+ return exec('begin', 'savepoint');
300
300
  }
301
301
 
302
302
  function commit() {
303
- return exec(`commit`, `release savepoint`);
303
+ return exec('commit', 'release savepoint');
304
304
  }
305
305
 
306
306
  function rollback() {
307
- return exec(`rollback`, `rollback to savepoint`);
307
+ return exec('rollback', 'rollback to savepoint');
308
308
  }
309
309
 
310
310
  function exec(top, nested) {
311
311
  if (ctx.txLevel) {
312
- return obj.none((capSQL ? nested.toUpperCase() : nested) + ` ` + spName);
312
+ return obj.none((capSQL ? nested.toUpperCase() : nested) + ' ' + spName);
313
313
  }
314
314
  return obj.none(capSQL ? top.toUpperCase() : top);
315
315
  }