orange-orm 4.4.0-beta.1 → 4.5.0-beta.0

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 CHANGED
@@ -40,7 +40,7 @@ If you value the hard work behind Orange and wish to see it evolve further, cons
40
40
  ## Installation
41
41
 
42
42
  ```bash
43
- $ npm install orange-orm
43
+ npm install orange-orm
44
44
  ```
45
45
 
46
46
  ## Example
@@ -50,7 +50,7 @@ Watch the [tutorial video on YouTube](https://youtu.be/1IwwjPr2lMs)
50
50
 
51
51
  Here we choose SQLite.
52
52
  ```bash
53
- $ npm install sqlite3
53
+ npm install sqlite3
54
54
  ```
55
55
  <sub>📄 map.ts</sub>
56
56
  ```javascript
@@ -280,7 +280,7 @@ In SQLite, columns with the INTEGER PRIMARY KEY attribute are designed to autoin
280
280
 
281
281
  __SQLite__
282
282
  ```bash
283
- $ npm install sqlite3
283
+ npm install sqlite3
284
284
  ```
285
285
  ```javascript
286
286
  import map from './map';
@@ -288,7 +288,7 @@ const db = map.sqlite('demo.db');
288
288
  ```
289
289
  __With connection pool__
290
290
  ```bash
291
- $ npm install sqlite3
291
+ npm install sqlite3
292
292
  ```
293
293
  ```javascript
294
294
  import map from './map';
@@ -331,7 +331,7 @@ const db = map.mysql('mysql://test:test@mysql/test');
331
331
 
332
332
  __MS SQL__
333
333
  ```bash
334
- $ npm install tedious
334
+ npm install tedious
335
335
  ```
336
336
  ```javascript
337
337
  import map from './map';
@@ -353,7 +353,7 @@ const db = map.mssql({
353
353
 
354
354
  __PostgreSQL__
355
355
  ```bash
356
- $ npm install pg
356
+ npm install pg
357
357
  ```
358
358
  ```javascript
359
359
  import map from './map';
@@ -361,7 +361,7 @@ const db = map.postgres('postgres://postgres:postgres@postgres/postgres');
361
361
  ```
362
362
  __Oracle__
363
363
  ```bash
364
- $ npm install oracledb
364
+ npm install oracledb
365
365
  ```
366
366
  ```javascript
367
367
  import map from './map';
@@ -375,7 +375,7 @@ const db = map.oracle({
375
375
  __SAP Adaptive Server__
376
376
  Even though msnodesqlv8 was developed for MS SQL, it also works for SAP ASE as it is ODBC compliant.
377
377
  ```bash
378
- $ npm install msnodesqlv8
378
+ npm install msnodesqlv8
379
379
  ```
380
380
  ```javascript
381
381
  import { fileURLToPath } from 'url';
package/docs/changelog.md CHANGED
@@ -1,4 +1,8 @@
1
1
  ## Changelog
2
+ __4.4.0__
3
+ More performance gains.
4
+ __4.3.0__
5
+ Minor performance improvements.
2
6
  __4.2.0__
3
7
  Improved performance.
4
8
  __4.1.4__
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orange-orm",
3
- "version": "4.4.0-beta.1",
3
+ "version": "4.5.0-beta.0",
4
4
  "main": "./src/index.js",
5
5
  "browser": "./src/client/index.mjs",
6
6
  "bin": {
@@ -48,7 +48,7 @@
48
48
  "lint": "eslint ./",
49
49
  "fix": "eslint ./ --fix",
50
50
  "owasp": "owasp-dependency-check --project \"MY_PROJECT\" --scan \"package-lock.json\" --exclude \"dependency-check-bin\" --out \"owasp\" --format HTML",
51
- "beta": "publish --tag beta"
51
+ "beta": "npm publish --tag beta"
52
52
  },
53
53
  "dependencies": {
54
54
  "@lroal/on-change": "^4.0.2",
@@ -66,7 +66,8 @@
66
66
  "node-cls": "^1.0.5",
67
67
  "promise": "^8.0.3",
68
68
  "rfdc": "^1.2.0",
69
- "uuid": "^8.3.2"
69
+ "uuid": "^8.3.2",
70
+ "wrangler": "^3.86.0"
70
71
  },
71
72
  "peerDependencies": {
72
73
  "msnodesqlv8": "^4.1.0",
@@ -102,6 +103,8 @@
102
103
  }
103
104
  },
104
105
  "devDependencies": {
106
+ "@cloudflare/workers-types": "^4.20241106.0",
107
+ "@miniflare/d1": "^2.14.4",
105
108
  "@rollup/plugin-commonjs": "^21.0.1",
106
109
  "@rollup/plugin-node-resolve": "^13.0.0",
107
110
  "@typescript-eslint/eslint-plugin": "^6.x",
@@ -39,6 +39,7 @@ function map(index, _fn) {
39
39
  dbMap.sap = throwDb;
40
40
  dbMap.oracle = throwDb;
41
41
  dbMap.sqlite = throwDb;
42
+ dbMap.d1 = throwDb;
42
43
 
43
44
  function throwDb() {
44
45
  throw new Error('Cannot create pool for database outside node');
@@ -65,6 +66,7 @@ function map(index, _fn) {
65
66
  onFinal.sap = () => index({ db: throwDb, providers: dbMap });
66
67
  onFinal.oracle = () => index({ db: throwDb, providers: dbMap });
67
68
  onFinal.sqlite = () => index({ db: throwDb, providers: dbMap });
69
+ onFinal.d1 = () => index({ db: throwDb, providers: dbMap });
68
70
 
69
71
  return new Proxy(onFinal, handler);
70
72
  }
@@ -48,6 +48,11 @@ function createProviders(index) {
48
48
  return createPool.bind(null, 'sqlite');
49
49
  }
50
50
  });
51
+ Object.defineProperty(dbMap, 'd1', {
52
+ get: function() {
53
+ return createPool.bind(null, 'd1');
54
+ }
55
+ });
51
56
  Object.defineProperty(dbMap, 'http', {
52
57
  get: function() {
53
58
  return createPool.bind(null, 'http');
@@ -97,12 +102,19 @@ function negotiateCachedPool(fn, providers) {
97
102
  get sqlite() {
98
103
  return createPool.bind(null, 'sqlite');
99
104
  },
105
+ get d1() {
106
+ return createPool.bind(null, 'd1');
107
+ },
100
108
  get http() {
101
109
  return createPool.bind(null, 'http');
102
110
  }
103
111
  };
104
112
 
105
113
  function createPool(providerName, ...args) {
114
+ //todo
115
+ if (providerName === 'd1') {
116
+ return providers[providerName].apply(null, args);
117
+ }
106
118
  const key = JSON.stringify(args);
107
119
  if (!cache[providerName])
108
120
  cache[providerName] = {};
@@ -57,6 +57,7 @@ function rdbClient(options = {}) {
57
57
  client.mssqlNative = onProvider.bind(null, 'mssqlNative');
58
58
  client.pg = onProvider.bind(null, 'pg');
59
59
  client.postgres = onProvider.bind(null, 'postgres');
60
+ client.d1 = onProvider.bind(null, 'd1');
60
61
  client.sqlite = onProvider.bind(null, 'sqlite');
61
62
  client.sap = onProvider.bind(null, 'sap');
62
63
  client.oracle = onProvider.bind(null, 'oracle');
@@ -128,7 +129,8 @@ function rdbClient(options = {}) {
128
129
  }
129
130
 
130
131
  async function query() {
131
- return netAdapter(baseUrl, undefined, { tableOptions: { db: baseUrl, transaction } }).query.apply(null, arguments);
132
+ const adapter = netAdapter(baseUrl, undefined, { tableOptions: { db: baseUrl, transaction } });
133
+ return adapter.query.apply(null, arguments);
132
134
  }
133
135
 
134
136
  function express(arg) {