orange-orm 4.6.0 → 4.7.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 +24 -15
- package/dist/index.browser.mjs +22 -6
- package/dist/index.mjs +667 -216
- package/package.json +9 -4
- package/src/bunPg/newTransaction.js +0 -2
- package/src/client/clientMap.js +2 -0
- package/src/client/createProviders.js +8 -0
- package/src/client/index.js +1 -0
- package/src/client/map.js +1 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +8 -0
- package/src/map.d.ts +3 -0
- package/src/pglite/newDatabase.js +135 -0
- package/src/pglite/newPool.js +19 -0
- package/src/pglite/newTransaction.js +83 -0
- package/src/pglite/pool/end.js +14 -0
- package/src/pglite/pool/newPgPool.js +96 -0
- package/src/pglite/wrapQuery.js +27 -0
- package/src/pglite.d.ts +64 -0
- package/src/table/column/boolean/newEncode.js +7 -3
- package/src/table/column/json/newEncode.js +3 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<img src="./docs/orange.svg" alt="Orange ORM Logo" width="250"/>
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
|
-
The ultimate Object Relational Mapper for Node.js and
|
|
5
|
+
The ultimate Object Relational Mapper for Node.js, Bun and Deno, offering seamless integration with a variety of popular databases. Orange ORM supports both TypeScript and JavaScript, including both CommonJS and ECMAScript.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.org/package/orange-orm)
|
|
8
8
|
[](https://github.com/alfateam/orange-orm/actions)
|
|
@@ -23,15 +23,16 @@ The ultimate Object Relational Mapper for Node.js and Typescript, offering seaml
|
|
|
23
23
|
- **Works in the Browser**: You can securely use Orange in the browser by utilizing the Express.js plugin, which serves to safeguard sensitive database credentials from exposure at the client level and protect against SQL injection. This method mirrors a traditional REST API, augmented with advanced TypeScript tooling for enhanced functionality.
|
|
24
24
|
|
|
25
25
|
## Supported Databases and Runtimes
|
|
26
|
-
| | Node | Deno | Bun |Cloudflare |
|
|
27
|
-
| ------------- | :-----: | :-----: | :-----: | :-----: |
|
|
28
|
-
| Postgres | ✅ | ✅ | ✅ |
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
26
|
+
| | Node | Deno | Bun |Cloudflare | Web |
|
|
27
|
+
| ------------- | :-----: | :-----: | :-----: | :-----: | :-----: |
|
|
28
|
+
| Postgres | ✅ | ✅ | ✅ | ✅|
|
|
29
|
+
| PGlite | ✅ | ✅ | ✅ | ✅ | ✅
|
|
30
|
+
| MS SQL | ✅ | | ✅ | |
|
|
31
|
+
| MySQL | ✅ | ✅ | ✅ ||
|
|
32
|
+
| Oracle | ✅ | ✅ | ✅ | |
|
|
33
|
+
| SAP ASE | ✅ | | | |
|
|
34
|
+
| SQLite | ✅ | ✅ | ✅ | |
|
|
35
|
+
| Cloudflare D1 | | | | ✅|
|
|
35
36
|
|
|
36
37
|
This is the _Modern Typescript Documentation_. Are you looking for the [_Classic Documentation_](https://github.com/alfateam/orange-orm/blob/master/docs/docs.md) ?
|
|
37
38
|
|
|
@@ -276,13 +277,11 @@ In SQLite, columns with the INTEGER PRIMARY KEY attribute are designed to autoin
|
|
|
276
277
|
<details><summary><strong>Connecting</strong></summary>
|
|
277
278
|
|
|
278
279
|
__SQLite__
|
|
279
|
-
|
|
280
|
-
|
|
280
|
+
When running **Node.js 21 and earlier**, you need to install the `sqlite3` dependency.
|
|
281
|
+
When running Node.js 22 and later, Bun, or Deno, you don't need it as it is built-in.
|
|
281
282
|
```bash
|
|
282
283
|
npm install sqlite3
|
|
283
284
|
```
|
|
284
|
-
__Node.js 22+, Bun, or Deno__
|
|
285
|
-
When running Node.js 22 and later, Bun, or Deno, you can use the builtin SQLite dependency and don't need to install sqlite3.
|
|
286
285
|
|
|
287
286
|
```javascript
|
|
288
287
|
import map from './map';
|
|
@@ -355,7 +354,7 @@ const db = map.mssql({
|
|
|
355
354
|
```
|
|
356
355
|
|
|
357
356
|
__PostgreSQL__
|
|
358
|
-
With Bun, you don't need to install the
|
|
357
|
+
With Bun, you don't need to install the `pg` package as PostgreSQL support is built-in.
|
|
359
358
|
```bash
|
|
360
359
|
npm install pg
|
|
361
360
|
```
|
|
@@ -368,6 +367,16 @@ With schema
|
|
|
368
367
|
import map from './map';
|
|
369
368
|
const db = map.postgres('postgres://postgres:postgres@postgres/postgres?search_path=custom');
|
|
370
369
|
```
|
|
370
|
+
__PGlite__
|
|
371
|
+
```bash
|
|
372
|
+
npm install @electric-sql/pglite
|
|
373
|
+
```
|
|
374
|
+
In this example we use the in-memory Postgres.
|
|
375
|
+
Read more about [PGLite connection configs](https://pglite.dev/docs/).
|
|
376
|
+
```javascript
|
|
377
|
+
import map from './map';
|
|
378
|
+
const db = map.pglite( /* config? : PGliteOptions */);
|
|
379
|
+
```
|
|
371
380
|
__Cloudflare D1__
|
|
372
381
|
<sub>📄 wrangler.toml</sub>
|
|
373
382
|
```toml
|
package/dist/index.browser.mjs
CHANGED
|
@@ -2537,6 +2537,7 @@ function requireClientMap () {
|
|
|
2537
2537
|
|
|
2538
2538
|
dbMap.http = (url) => url;
|
|
2539
2539
|
dbMap.pg = throwDb;
|
|
2540
|
+
dbMap.pglite = throwDb;
|
|
2540
2541
|
dbMap.postgres = throwDb;
|
|
2541
2542
|
dbMap.mssql = throwDb;
|
|
2542
2543
|
dbMap.mssqlNative = throwDb;
|
|
@@ -2564,6 +2565,7 @@ function requireClientMap () {
|
|
|
2564
2565
|
|
|
2565
2566
|
onFinal.http = (url) => index({ db: url, providers: dbMap });
|
|
2566
2567
|
onFinal.pg = () => index({ db: throwDb, providers: dbMap });
|
|
2568
|
+
onFinal.pglite = () => index({ db: throwDb, providers: dbMap });
|
|
2567
2569
|
onFinal.postgres = () => index({ db: throwDb, providers: dbMap });
|
|
2568
2570
|
onFinal.mssql = () => index({ db: throwDb, providers: dbMap });
|
|
2569
2571
|
onFinal.mssqlNative = () => index({ db: throwDb, providers: dbMap });
|
|
@@ -2716,6 +2718,7 @@ function requireClient () {
|
|
|
2716
2718
|
client.mssql = onProvider.bind(null, 'mssql');
|
|
2717
2719
|
client.mssqlNative = onProvider.bind(null, 'mssqlNative');
|
|
2718
2720
|
client.pg = onProvider.bind(null, 'pg');
|
|
2721
|
+
client.pglite = onProvider.bind(null, 'pglite');
|
|
2719
2722
|
client.postgres = onProvider.bind(null, 'postgres');
|
|
2720
2723
|
client.d1 = onProvider.bind(null, 'd1');
|
|
2721
2724
|
client.sqlite = onProvider.bind(null, 'sqlite');
|
|
@@ -4593,7 +4596,7 @@ function requireNewEncode$6 () {
|
|
|
4593
4596
|
return newPara('null');
|
|
4594
4597
|
return newPara('\'' + column.dbNull + '\'');
|
|
4595
4598
|
}
|
|
4596
|
-
var encodeCore = getSessionSingleton(context, 'encodeJSON');
|
|
4599
|
+
var encodeCore = getSessionSingleton(context, 'encodeJSON') || ((v) => v);
|
|
4597
4600
|
|
|
4598
4601
|
if (encodeCore) {
|
|
4599
4602
|
value = encodeCore(value);
|
|
@@ -4609,7 +4612,7 @@ function requireNewEncode$6 () {
|
|
|
4609
4612
|
return 'null';
|
|
4610
4613
|
return '\'' + column.dbNull + '\'';
|
|
4611
4614
|
}
|
|
4612
|
-
var encodeCore = getSessionSingleton(context, 'encodeJSON');
|
|
4615
|
+
var encodeCore = getSessionSingleton(context, 'encodeJSON') || ((v) => v);
|
|
4613
4616
|
|
|
4614
4617
|
if (encodeCore) {
|
|
4615
4618
|
value = encodeCore(value);
|
|
@@ -4618,7 +4621,7 @@ function requireNewEncode$6 () {
|
|
|
4618
4621
|
};
|
|
4619
4622
|
|
|
4620
4623
|
encode.direct = function(context, value) {
|
|
4621
|
-
var encodeCore = getSessionSingleton(context, 'encodeJSON');
|
|
4624
|
+
var encodeCore = getSessionSingleton(context, 'encodeJSON') || ((v) => v);
|
|
4622
4625
|
|
|
4623
4626
|
if (encodeCore) {
|
|
4624
4627
|
value = encodeCore(value);
|
|
@@ -5217,7 +5220,7 @@ function requireNewEncode$1 () {
|
|
|
5217
5220
|
return newParam('null');
|
|
5218
5221
|
return newParam('\'' + column.dbNull + '\'');
|
|
5219
5222
|
}
|
|
5220
|
-
var encodeCore = getSessionSingleton(context, 'encodeBoolean');
|
|
5223
|
+
var encodeCore = getSessionSingleton(context, 'encodeBoolean') || encodeDefault;
|
|
5221
5224
|
|
|
5222
5225
|
|
|
5223
5226
|
return newParam('?', [encodeCore(value)]);
|
|
@@ -5230,14 +5233,14 @@ function requireNewEncode$1 () {
|
|
|
5230
5233
|
return 'null';
|
|
5231
5234
|
return '\'' + column.dbNull + '\'';
|
|
5232
5235
|
}
|
|
5233
|
-
var encodeCore = getSessionSingleton(context, 'encodeBoolean');
|
|
5236
|
+
var encodeCore = getSessionSingleton(context, 'encodeBoolean') || encodeDefault;
|
|
5234
5237
|
|
|
5235
5238
|
|
|
5236
5239
|
return encodeCore(value);
|
|
5237
5240
|
};
|
|
5238
5241
|
|
|
5239
5242
|
encode.direct = function(context, value) {
|
|
5240
|
-
var encodeCore = getSessionSingleton(context, 'encodeBoolean');
|
|
5243
|
+
var encodeCore = getSessionSingleton(context, 'encodeBoolean') || encodeDefault;
|
|
5241
5244
|
|
|
5242
5245
|
return encodeCore(value);
|
|
5243
5246
|
};
|
|
@@ -5245,6 +5248,10 @@ function requireNewEncode$1 () {
|
|
|
5245
5248
|
return encode;
|
|
5246
5249
|
}
|
|
5247
5250
|
|
|
5251
|
+
function encodeDefault(value) {
|
|
5252
|
+
return value;
|
|
5253
|
+
}
|
|
5254
|
+
|
|
5248
5255
|
newEncode$1 = _new;
|
|
5249
5256
|
return newEncode$1;
|
|
5250
5257
|
}
|
|
@@ -11863,6 +11870,11 @@ function requireCreateProviders () {
|
|
|
11863
11870
|
return createPool.bind(null, 'pg');
|
|
11864
11871
|
}
|
|
11865
11872
|
});
|
|
11873
|
+
Object.defineProperty(dbMap, 'pglite', {
|
|
11874
|
+
get: function() {
|
|
11875
|
+
return createPool.bind(null, 'pglite');
|
|
11876
|
+
}
|
|
11877
|
+
});
|
|
11866
11878
|
Object.defineProperty(dbMap, 'postgres', {
|
|
11867
11879
|
get: function() {
|
|
11868
11880
|
return createPool.bind(null, 'pg');
|
|
@@ -11931,6 +11943,9 @@ function requireCreateProviders () {
|
|
|
11931
11943
|
get pg() {
|
|
11932
11944
|
return createPool.bind(null, 'pg');
|
|
11933
11945
|
},
|
|
11946
|
+
get pglite() {
|
|
11947
|
+
return createPool.bind(null, 'pglite');
|
|
11948
|
+
},
|
|
11934
11949
|
get postgres() {
|
|
11935
11950
|
return createPool.bind(null, 'pg');
|
|
11936
11951
|
},
|
|
@@ -12033,6 +12048,7 @@ function requireMap () {
|
|
|
12033
12048
|
}
|
|
12034
12049
|
context.map = map.bind(null, index, context, providers);
|
|
12035
12050
|
context.pg = connect.bind(null, 'pg');
|
|
12051
|
+
context.pglite = connect.bind(null, 'pglite');
|
|
12036
12052
|
context.postgres = connect.bind(null, 'pg');
|
|
12037
12053
|
context.mssql = connect.bind(null, 'mssql');
|
|
12038
12054
|
context.mssqlNative = connect.bind(null, 'mssqlNative');
|