orange-orm 4.5.0-beta.2 → 4.5.0-beta.4
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.
- package/README.md +38 -1
- package/docs/changelog.md +2 -0
- package/package.json +4 -7
- package/src/applyPatch.js +7 -3
- package/src/client/index.mjs +25 -20
- package/src/validateDeleteConflict.js +7 -3
- package/src/clsTest.js +0 -79
- package/src/mySql/wrapQueryStream.js +0 -9
- package/src/pg/newStreamableQuery.js +0 -7
- package/src/pg/wrapQueryStream.js +0 -20
- package/src/table/getManyDto/pg/newQuery.js +0 -8
package/README.md
CHANGED
|
@@ -29,7 +29,8 @@ The ultimate Object Relational Mapper for Node.js and Typescript, offering seaml
|
|
|
29
29
|
✅ MySQL
|
|
30
30
|
✅ Oracle
|
|
31
31
|
✅ SAP ASE
|
|
32
|
-
✅ SQLite
|
|
32
|
+
✅ SQLite
|
|
33
|
+
✅ Cloudflare D1
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
This is the _Modern Typescript Documentation_. Are you looking for the [_Classic Documentation_](https://github.com/alfateam/orange-orm/blob/master/docs/docs.md) ?
|
|
@@ -319,6 +320,7 @@ import map from './map';
|
|
|
319
320
|
|
|
320
321
|
const db = map.http('http://localhost:3000/orange');
|
|
321
322
|
```
|
|
323
|
+
|
|
322
324
|
__MySQL__
|
|
323
325
|
```bash
|
|
324
326
|
$ npm install mysql2
|
|
@@ -364,6 +366,38 @@ With schema
|
|
|
364
366
|
import map from './map';
|
|
365
367
|
const db = map.postgres('postgres://postgres:postgres@postgres/postgres?search_path=custom');
|
|
366
368
|
```
|
|
369
|
+
__Cloudflare D1__
|
|
370
|
+
<sub>📄 wrangler.toml</sub>
|
|
371
|
+
```toml
|
|
372
|
+
name = "d1-tutorial"
|
|
373
|
+
main = "src/index.ts"
|
|
374
|
+
compatibility_date = "2025-02-04"
|
|
375
|
+
|
|
376
|
+
# Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
|
|
377
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
|
|
378
|
+
[[d1_databases]]
|
|
379
|
+
binding = "DB"
|
|
380
|
+
database_name = "<your-name-for-the-database>"
|
|
381
|
+
database_id = "<your-guid-for-the-database>"
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
<sub>📄 scr/index.ts</sub>
|
|
385
|
+
```javascript
|
|
386
|
+
import map from './map';
|
|
387
|
+
|
|
388
|
+
export interface Env {
|
|
389
|
+
// Must match the binding name in wrangler.toml
|
|
390
|
+
DB: D1Database;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export default {
|
|
394
|
+
async fetch(request, env): Promise<Response> {
|
|
395
|
+
const db = map.d1(env.DB);
|
|
396
|
+
const customers = await db.customer.getAll();
|
|
397
|
+
return Response.json(customers);
|
|
398
|
+
},
|
|
399
|
+
} satisfies ExportedHandler<Env>;
|
|
400
|
+
```
|
|
367
401
|
__Oracle__
|
|
368
402
|
```bash
|
|
369
403
|
npm install oracledb
|
|
@@ -1580,6 +1614,8 @@ async function getRows() {
|
|
|
1580
1614
|
Within the transaction, a customer is retrieved and its balance updated using the tx object to ensure operations are transactional.
|
|
1581
1615
|
An error is deliberately thrown to demonstrate a rollback, ensuring all previous changes within the transaction are reverted.
|
|
1582
1616
|
Always use the provided tx object for operations within the transaction to maintain data integrity.</p>
|
|
1617
|
+
<p>(NOTE: Transactions are not supported for Cloudflare D1)</p>
|
|
1618
|
+
|
|
1583
1619
|
|
|
1584
1620
|
```javascript
|
|
1585
1621
|
import map from './map';
|
|
@@ -1597,6 +1633,7 @@ async function execute() {
|
|
|
1597
1633
|
}
|
|
1598
1634
|
|
|
1599
1635
|
```
|
|
1636
|
+
|
|
1600
1637
|
</details>
|
|
1601
1638
|
|
|
1602
1639
|
<details><summary><strong>Data types</strong></summary>
|
package/docs/changelog.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orange-orm",
|
|
3
|
-
"version": "4.5.0-beta.
|
|
3
|
+
"version": "4.5.0-beta.4",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"browser": "./src/client/index.mjs",
|
|
6
6
|
"bin": {
|
|
@@ -54,19 +54,17 @@
|
|
|
54
54
|
"@lroal/on-change": "^4.0.2",
|
|
55
55
|
"@tediousjs/connection-string": "^0.4.1",
|
|
56
56
|
"@types/express": "^4.17.13",
|
|
57
|
+
"@cloudflare/workers-types": "^4.20241106.0",
|
|
57
58
|
"@types/oracledb": "^6.0.4",
|
|
58
59
|
"@types/tedious": "^4.0.14",
|
|
59
60
|
"ajv": "^6.10.2",
|
|
60
|
-
"assert": "^2.1.0",
|
|
61
61
|
"axios": "^1.6.2",
|
|
62
62
|
"fast-json-patch": "^3.1.1",
|
|
63
63
|
"findup-sync": "^5.0.0",
|
|
64
64
|
"glob": "^10.3.4",
|
|
65
65
|
"module-definition": "^4.0.0",
|
|
66
|
-
"node-cls": "^1.0.5",
|
|
67
66
|
"rfdc": "^1.2.0",
|
|
68
|
-
"uuid": "^8.3.2"
|
|
69
|
-
"wrangler": "^3.107.2"
|
|
67
|
+
"uuid": "^8.3.2"
|
|
70
68
|
},
|
|
71
69
|
"peerDependencies": {
|
|
72
70
|
"msnodesqlv8": "^4.1.0",
|
|
@@ -104,8 +102,7 @@
|
|
|
104
102
|
"optional": true
|
|
105
103
|
}
|
|
106
104
|
},
|
|
107
|
-
"devDependencies": {
|
|
108
|
-
"@cloudflare/workers-types": "^4.20241106.0",
|
|
105
|
+
"devDependencies": {
|
|
109
106
|
"@miniflare/d1": "^2.14.4",
|
|
110
107
|
"@rollup/plugin-commonjs": "^28.0.2",
|
|
111
108
|
"@rollup/plugin-json": "^6.1.0",
|
package/src/applyPatch.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const fastjson = require('fast-json-patch');
|
|
2
|
-
let assert = require('assert');
|
|
3
2
|
let fromCompareObject = require('./fromCompareObject');
|
|
4
3
|
let toCompareObject = require('./toCompareObject');
|
|
5
4
|
|
|
@@ -42,7 +41,7 @@ function applyPatch({ options = {} }, dto, changes, column) {
|
|
|
42
41
|
assertDatesEqual(oldValue, expectedOldValue);
|
|
43
42
|
}
|
|
44
43
|
else
|
|
45
|
-
|
|
44
|
+
assertDeepEqual(oldValue, expectedOldValue);
|
|
46
45
|
}
|
|
47
46
|
catch (e) {
|
|
48
47
|
if (concurrency === 'skipOnConflict')
|
|
@@ -98,7 +97,12 @@ function assertDatesEqual(date1, date2) {
|
|
|
98
97
|
date1 = `${parts1[0]}T${time1parts[0]}`;
|
|
99
98
|
date2 = `${parts2[0]}T${time2parts[0]}`;
|
|
100
99
|
}
|
|
101
|
-
|
|
100
|
+
assertDeepEqual(date1, date2);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function assertDeepEqual(a, b) {
|
|
104
|
+
if (JSON.stringify(a) !== JSON.stringify(b))
|
|
105
|
+
throw new Error('A, b are not equal');
|
|
102
106
|
}
|
|
103
107
|
|
|
104
108
|
function inspect(obj) {
|
package/src/client/index.mjs
CHANGED
|
@@ -7,7 +7,6 @@ import * as axios from 'axios';
|
|
|
7
7
|
import * as _default from 'rfdc/default';
|
|
8
8
|
import * as ajv from 'ajv';
|
|
9
9
|
import * as onChange from '@lroal/on-change';
|
|
10
|
-
import * as assert from 'assert';
|
|
11
10
|
|
|
12
11
|
function getDefaultExportFromCjs (x) {
|
|
13
12
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -724,7 +723,7 @@ function requireHostExpress () {
|
|
|
724
723
|
return hostExpress_1;
|
|
725
724
|
}
|
|
726
725
|
|
|
727
|
-
var require$$0$
|
|
726
|
+
var require$$0$3 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(fastJsonPatch);
|
|
728
727
|
|
|
729
728
|
var dateToISOString_1;
|
|
730
729
|
var hasRequiredDateToISOString;
|
|
@@ -784,7 +783,7 @@ function requireStringify () {
|
|
|
784
783
|
return stringify_1;
|
|
785
784
|
}
|
|
786
785
|
|
|
787
|
-
var require$$0$
|
|
786
|
+
var require$$0$2 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(uuid);
|
|
788
787
|
|
|
789
788
|
var createPatch;
|
|
790
789
|
var hasRequiredCreatePatch;
|
|
@@ -792,10 +791,10 @@ var hasRequiredCreatePatch;
|
|
|
792
791
|
function requireCreatePatch () {
|
|
793
792
|
if (hasRequiredCreatePatch) return createPatch;
|
|
794
793
|
hasRequiredCreatePatch = 1;
|
|
795
|
-
const jsonpatch = require$$0$
|
|
794
|
+
const jsonpatch = require$$0$3;
|
|
796
795
|
let dateToIsoString = requireDateToISOString();
|
|
797
796
|
let stringify = requireStringify();
|
|
798
|
-
let { v4: uuid } = require$$0$
|
|
797
|
+
let { v4: uuid } = require$$0$2;
|
|
799
798
|
|
|
800
799
|
createPatch = function createPatch(original, dto, options) {
|
|
801
800
|
let subject = toCompareObject({ d: original }, options, true);
|
|
@@ -2315,7 +2314,7 @@ function requireCloneFromDb () {
|
|
|
2315
2314
|
return cloneFromDb_1;
|
|
2316
2315
|
}
|
|
2317
2316
|
|
|
2318
|
-
var require$$0$
|
|
2317
|
+
var require$$0$1 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(axios);
|
|
2319
2318
|
|
|
2320
2319
|
var netAdapter_1;
|
|
2321
2320
|
var hasRequiredNetAdapter;
|
|
@@ -2323,7 +2322,7 @@ var hasRequiredNetAdapter;
|
|
|
2323
2322
|
function requireNetAdapter () {
|
|
2324
2323
|
if (hasRequiredNetAdapter) return netAdapter_1;
|
|
2325
2324
|
hasRequiredNetAdapter = 1;
|
|
2326
|
-
const _axios = require$$0$
|
|
2325
|
+
const _axios = require$$0$1;
|
|
2327
2326
|
|
|
2328
2327
|
function httpAdapter(baseURL, path, axiosInterceptor) {
|
|
2329
2328
|
//@ts-ignore
|
|
@@ -2466,7 +2465,7 @@ function requireToKeyPositionMap () {
|
|
|
2466
2465
|
if (hasRequiredToKeyPositionMap) return toKeyPositionMap_1;
|
|
2467
2466
|
hasRequiredToKeyPositionMap = 1;
|
|
2468
2467
|
const stringify = requireStringify();
|
|
2469
|
-
const { v4: uuid } = require$$0$
|
|
2468
|
+
const { v4: uuid } = require$$0$2;
|
|
2470
2469
|
|
|
2471
2470
|
function toKeyPositionMap(rows, options) {
|
|
2472
2471
|
return rows.reduce((map, element, i) => {
|
|
@@ -4053,7 +4052,7 @@ function requireNewColumn () {
|
|
|
4053
4052
|
return newColumn;
|
|
4054
4053
|
}
|
|
4055
4054
|
|
|
4056
|
-
var require$$0
|
|
4055
|
+
var require$$0 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(ajv);
|
|
4057
4056
|
|
|
4058
4057
|
var purify_1$5;
|
|
4059
4058
|
var hasRequiredPurify$6;
|
|
@@ -5216,7 +5215,7 @@ var hasRequiredColumn;
|
|
|
5216
5215
|
function requireColumn () {
|
|
5217
5216
|
if (hasRequiredColumn) return column;
|
|
5218
5217
|
hasRequiredColumn = 1;
|
|
5219
|
-
const Ajv = require$$0
|
|
5218
|
+
const Ajv = require$$0;
|
|
5220
5219
|
|
|
5221
5220
|
function defineColumn(column, table) {
|
|
5222
5221
|
var c = {};
|
|
@@ -7004,8 +7003,6 @@ function requireToDto () {
|
|
|
7004
7003
|
return toDto_1;
|
|
7005
7004
|
}
|
|
7006
7005
|
|
|
7007
|
-
var require$$0 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(assert);
|
|
7008
|
-
|
|
7009
7006
|
var fromCompareObject_1;
|
|
7010
7007
|
var hasRequiredFromCompareObject;
|
|
7011
7008
|
|
|
@@ -7095,8 +7092,7 @@ var hasRequiredApplyPatch;
|
|
|
7095
7092
|
function requireApplyPatch () {
|
|
7096
7093
|
if (hasRequiredApplyPatch) return applyPatch_1;
|
|
7097
7094
|
hasRequiredApplyPatch = 1;
|
|
7098
|
-
const fastjson = require$$0$
|
|
7099
|
-
let assert = require$$0;
|
|
7095
|
+
const fastjson = require$$0$3;
|
|
7100
7096
|
let fromCompareObject = requireFromCompareObject();
|
|
7101
7097
|
let toCompareObject = requireToCompareObject();
|
|
7102
7098
|
|
|
@@ -7139,7 +7135,7 @@ function requireApplyPatch () {
|
|
|
7139
7135
|
assertDatesEqual(oldValue, expectedOldValue);
|
|
7140
7136
|
}
|
|
7141
7137
|
else
|
|
7142
|
-
|
|
7138
|
+
assertDeepEqual(oldValue, expectedOldValue);
|
|
7143
7139
|
}
|
|
7144
7140
|
catch (e) {
|
|
7145
7141
|
if (concurrency === 'skipOnConflict')
|
|
@@ -7195,7 +7191,12 @@ function requireApplyPatch () {
|
|
|
7195
7191
|
date1 = `${parts1[0]}T${time1parts[0]}`;
|
|
7196
7192
|
date2 = `${parts2[0]}T${time2parts[0]}`;
|
|
7197
7193
|
}
|
|
7198
|
-
|
|
7194
|
+
assertDeepEqual(date1, date2);
|
|
7195
|
+
}
|
|
7196
|
+
|
|
7197
|
+
function assertDeepEqual(a, b) {
|
|
7198
|
+
if (JSON.stringify(a) !== JSON.stringify(b))
|
|
7199
|
+
throw new Error('A, b are not equal');
|
|
7199
7200
|
}
|
|
7200
7201
|
|
|
7201
7202
|
function inspect(obj) {
|
|
@@ -7214,7 +7215,6 @@ function requireValidateDeleteConflict () {
|
|
|
7214
7215
|
hasRequiredValidateDeleteConflict = 1;
|
|
7215
7216
|
// @ts-nocheck
|
|
7216
7217
|
/* eslint-disable */
|
|
7217
|
-
let assert = require$$0;
|
|
7218
7218
|
const toCompareObject = requireToCompareObject();
|
|
7219
7219
|
|
|
7220
7220
|
async function validateDeleteConflict({ row, oldValue, options, table }) {
|
|
@@ -7229,7 +7229,7 @@ function requireValidateDeleteConflict () {
|
|
|
7229
7229
|
assertDatesEqual(oldValue[p], toCompareObject(row[p]));
|
|
7230
7230
|
}
|
|
7231
7231
|
else
|
|
7232
|
-
|
|
7232
|
+
assertDeepEqual(oldValue[p], toCompareObject(row[p]));
|
|
7233
7233
|
}
|
|
7234
7234
|
catch (e) {
|
|
7235
7235
|
throw new Error(`The field ${p} was changed by another user. Expected ${inspect(oldValue[p])}, but was ${inspect(row[p])}.`);
|
|
@@ -7298,7 +7298,12 @@ function requireValidateDeleteConflict () {
|
|
|
7298
7298
|
date1 = `${parts1[0]}T${time1parts[0]}`;
|
|
7299
7299
|
date2 = `${parts2[0]}T${time2parts[0]}`;
|
|
7300
7300
|
}
|
|
7301
|
-
|
|
7301
|
+
assertDeepEqual(date1, date2);
|
|
7302
|
+
}
|
|
7303
|
+
|
|
7304
|
+
function assertDeepEqual(a, b) {
|
|
7305
|
+
if (JSON.stringify(a) !== JSON.stringify(b))
|
|
7306
|
+
throw new Error('A, b are not equal');
|
|
7302
7307
|
}
|
|
7303
7308
|
|
|
7304
7309
|
function inspect(obj) {
|
|
@@ -10043,7 +10048,7 @@ var hasRequiredNewId;
|
|
|
10043
10048
|
function requireNewId () {
|
|
10044
10049
|
if (hasRequiredNewId) return newId;
|
|
10045
10050
|
hasRequiredNewId = 1;
|
|
10046
|
-
const { v4 : uuid} = require$$0$
|
|
10051
|
+
const { v4 : uuid} = require$$0$2;
|
|
10047
10052
|
newId = uuid;
|
|
10048
10053
|
return newId;
|
|
10049
10054
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
let assert = require('assert');
|
|
4
3
|
const toCompareObject = require('./toCompareObject');
|
|
5
4
|
|
|
6
5
|
async function validateDeleteConflict({ row, oldValue, options, table }) {
|
|
@@ -15,7 +14,7 @@ async function validateDeleteConflict({ row, oldValue, options, table }) {
|
|
|
15
14
|
assertDatesEqual(oldValue[p], toCompareObject(row[p]));
|
|
16
15
|
}
|
|
17
16
|
else
|
|
18
|
-
|
|
17
|
+
assertDeepEqual(oldValue[p], toCompareObject(row[p]));
|
|
19
18
|
}
|
|
20
19
|
catch (e) {
|
|
21
20
|
throw new Error(`The field ${p} was changed by another user. Expected ${inspect(oldValue[p])}, but was ${inspect(row[p])}.`);
|
|
@@ -84,7 +83,12 @@ function assertDatesEqual(date1, date2) {
|
|
|
84
83
|
date1 = `${parts1[0]}T${time1parts[0]}`;
|
|
85
84
|
date2 = `${parts2[0]}T${time2parts[0]}`;
|
|
86
85
|
}
|
|
87
|
-
|
|
86
|
+
assertDeepEqual(date1, date2);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function assertDeepEqual(a, b) {
|
|
90
|
+
if (JSON.stringify(a) !== JSON.stringify(b))
|
|
91
|
+
throw new Error('A, b are not equal');
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
function inspect(obj) {
|
package/src/clsTest.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
let cls = require('node-cls');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const log = (str) => fs.writeSync(1, `${str}\n`);
|
|
4
|
-
|
|
5
|
-
function begin(id) {
|
|
6
|
-
return new Promise((resolve) => {
|
|
7
|
-
let context = cls.get();
|
|
8
|
-
context.id = id;
|
|
9
|
-
resolve();
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function getById() {
|
|
14
|
-
return new Promise((resolve) => {
|
|
15
|
-
let context = cls.get();
|
|
16
|
-
context.id;
|
|
17
|
-
resolve(context.id);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function getFromDb() {
|
|
22
|
-
let c = cls.create();
|
|
23
|
-
await c.start();
|
|
24
|
-
await begin(1);
|
|
25
|
-
await new Promise((resolve) => {
|
|
26
|
-
setTimeout(resolve(), 500);
|
|
27
|
-
});
|
|
28
|
-
await getFromDb2();
|
|
29
|
-
|
|
30
|
-
let c3 = cls.create();
|
|
31
|
-
await c3.start();
|
|
32
|
-
await begin(3);
|
|
33
|
-
let id3 = await getById();
|
|
34
|
-
if (id3 !== 3)
|
|
35
|
-
throw new Error('3 Unexpected context id : ' + id3);
|
|
36
|
-
cls.exit();
|
|
37
|
-
|
|
38
|
-
await getFromDb3();
|
|
39
|
-
|
|
40
|
-
let id = await getById();
|
|
41
|
-
if (id !== 1)
|
|
42
|
-
throw new Error('1 Unexpected context id : ' + id);
|
|
43
|
-
cls.exit();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function getFromDb2() {
|
|
47
|
-
return new Promise((resolve) => {
|
|
48
|
-
setTimeout(async () => {
|
|
49
|
-
let c2 = cls.create();
|
|
50
|
-
await c2.start();
|
|
51
|
-
await begin(2);
|
|
52
|
-
let id2 = await getById();
|
|
53
|
-
if (id2 !== 2)
|
|
54
|
-
throw new Error('2 Unexpected context id : ' + id2);
|
|
55
|
-
id2 = cls.active.id;
|
|
56
|
-
if (id2 !== 2)
|
|
57
|
-
throw new Error('2 Unexpected context id : ' + id2);
|
|
58
|
-
cls.exit();
|
|
59
|
-
resolve();
|
|
60
|
-
}, 500);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async function getFromDb3() {
|
|
65
|
-
let c3 = cls.create();
|
|
66
|
-
await c3.start();
|
|
67
|
-
await begin(3);
|
|
68
|
-
let id3 = await getById();
|
|
69
|
-
if (id3 !== 3)
|
|
70
|
-
throw new Error('3 Unexpected context id : ' + id3);
|
|
71
|
-
cls.exit();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
async function testStart() {
|
|
76
|
-
await getFromDb();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
testStart().then(() => log('done'), (e) => log(e.stack));
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
var log = require('../table/log');
|
|
2
|
-
var replaceParamChar = require('./replaceParamChar');
|
|
3
|
-
var newStreamableQuery = require('./newStreamableQuery');
|
|
4
|
-
|
|
5
|
-
function wrapQueryStream(connection) {
|
|
6
|
-
var runOriginalQuery = connection.query;
|
|
7
|
-
return runQuery;
|
|
8
|
-
|
|
9
|
-
function runQuery(query, options) {
|
|
10
|
-
var params = query.parameters;
|
|
11
|
-
var sql = replaceParamChar(query, params);
|
|
12
|
-
log.emitQuery({sql, parameters: params});
|
|
13
|
-
query = newStreamableQuery(sql, params, options);
|
|
14
|
-
|
|
15
|
-
return runOriginalQuery.call(connection, query);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
module.exports = wrapQueryStream;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
var newQueryCore = require('../../readStream/pg/newQueryCore');
|
|
2
|
-
|
|
3
|
-
function newQuery() {
|
|
4
|
-
var query = newQueryCore.apply(null, arguments);
|
|
5
|
-
return query.prepend('select json_strip_nulls(coalesce(json_agg(row_to_json(r)), \'[]\')) as result from (').append(') r');
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
module.exports = newQuery;
|