orange-orm 5.2.0-beta.0 → 5.2.1
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 +20 -37
- package/SKILL.md +1377 -0
- package/context7.json +4 -0
- package/dist/index.mjs +35 -20
- package/docs/changelog.md +6 -0
- package/package.json +4 -4
- package/src/bunPg/encodeJSON.js +6 -0
- package/src/bunPg/newTransaction.js +1 -1
- package/docs/docs.md +0 -2374
- package/other.db +0 -0
package/README.md
CHANGED
|
@@ -12,7 +12,10 @@ The ultimate Object Relational Mapper for Node.js, Bun and Deno, offering seamle
|
|
|
12
12
|
[](https://discord.gg/QjuEgvQXzd)
|
|
13
13
|
[](https://youtu.be/1IwwjPr2lMs)
|
|
14
14
|
|
|
15
|
+
## MCP (Model Context Protocol)
|
|
16
|
+
Orange ORM is available as an MCP resource on Context7. Use it with AI-powered tools like GitHub Copilot, Cursor, or Claude to get up-to-date documentation and code examples directly in your IDE.
|
|
15
17
|
|
|
18
|
+
👉 [https://context7.com/alfateam/orange-orm](https://context7.com/alfateam/orange-orm)
|
|
16
19
|
|
|
17
20
|
## Key Features
|
|
18
21
|
|
|
@@ -20,7 +23,7 @@ The ultimate Object Relational Mapper for Node.js, Bun and Deno, offering seamle
|
|
|
20
23
|
- **Active Record**: With a concise and expressive syntax, Orange enables you to interact with your database using the [*Active Record Pattern*](https://en.wikipedia.org/wiki/Active_record_pattern).
|
|
21
24
|
- **No Code Generation Required**: Enjoy full IntelliSense, even in table mappings, without the need for cumbersome code generation.
|
|
22
25
|
- **TypeScript and JavaScript Support**: Orange fully supports both TypeScript and JavaScript, allowing you to leverage the benefits of static typing and modern ECMAScript features.
|
|
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.
|
|
26
|
+
- **Works in the Browser**: You can securely use Orange in the browser by utilizing the Express.js or Hono 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
27
|
|
|
25
28
|
## Supported Databases and Runtimes
|
|
26
29
|
| | Node | Deno | Bun |Cloudflare | Web |
|
|
@@ -34,8 +37,6 @@ The ultimate Object Relational Mapper for Node.js, Bun and Deno, offering seamle
|
|
|
34
37
|
| SQLite | ✅ | ✅ | ✅ | |
|
|
35
38
|
| Cloudflare D1 | | | | ✅|
|
|
36
39
|
|
|
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) ?
|
|
38
|
-
|
|
39
40
|
## Sponsorship <span style="font-size: larger; color: darkred;">♡</span>
|
|
40
41
|
If you value the hard work behind Orange and wish to see it evolve further, consider [sponsoring](https://github.com/sponsors/lroal). Your support fuels the journey of refining and expanding this tool for our developer community.
|
|
41
42
|
|
|
@@ -634,8 +635,6 @@ The following operators are supported:
|
|
|
634
635
|
- max
|
|
635
636
|
- avg
|
|
636
637
|
|
|
637
|
-
For distinct rows across selected fields, you can use `table.distinct(...)`.
|
|
638
|
-
|
|
639
638
|
You can also elevate associated data to a parent level for easier access. In the example below, <i>balance</i> of the customer is elevated to the root level.
|
|
640
639
|
|
|
641
640
|
```javascript
|
|
@@ -653,19 +652,6 @@ async function getRows() {
|
|
|
653
652
|
}
|
|
654
653
|
```
|
|
655
654
|
|
|
656
|
-
```javascript
|
|
657
|
-
import map from './map';
|
|
658
|
-
const db = map.sqlite('demo.db');
|
|
659
|
-
|
|
660
|
-
getDistinct();
|
|
661
|
-
|
|
662
|
-
async function getDistinct() {
|
|
663
|
-
const rows = await db.orderLine.distinct({
|
|
664
|
-
orderId: x => x.orderId
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
```
|
|
668
|
-
|
|
669
655
|
__Many rows filtered__
|
|
670
656
|
|
|
671
657
|
```javascript
|
|
@@ -1806,6 +1792,21 @@ async function getRows() {
|
|
|
1806
1792
|
});
|
|
1807
1793
|
}
|
|
1808
1794
|
```
|
|
1795
|
+
__Count__
|
|
1796
|
+
Use <i>count</i> on a relation in a filter to compare how many related rows match a condition.
|
|
1797
|
+
```javascript
|
|
1798
|
+
import map from './map';
|
|
1799
|
+
const db = map.sqlite('demo.db');
|
|
1800
|
+
|
|
1801
|
+
getRows();
|
|
1802
|
+
|
|
1803
|
+
async function getRows() {
|
|
1804
|
+
const rows = await db.order.getMany({
|
|
1805
|
+
where: x => x.lines.count().le(1)
|
|
1806
|
+
.and(x.lines.count(line => line.product.contains('guitar')).eq(1))
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
```
|
|
1809
1810
|
|
|
1810
1811
|
</details>
|
|
1811
1812
|
|
|
@@ -2315,24 +2316,6 @@ async function getAggregates() {
|
|
|
2315
2316
|
}
|
|
2316
2317
|
```
|
|
2317
2318
|
|
|
2318
|
-
__Distinct__
|
|
2319
|
-
Use `distinct` when you want unique combinations of selected fields.
|
|
2320
|
-
When only plain columns are selected, this uses SQL `DISTINCT`.
|
|
2321
|
-
If aggregate expressions are included, it falls back to `GROUP BY`.
|
|
2322
|
-
|
|
2323
|
-
```javascript
|
|
2324
|
-
import map from './map';
|
|
2325
|
-
const db = map.sqlite('demo.db');
|
|
2326
|
-
|
|
2327
|
-
getDistinctRows();
|
|
2328
|
-
|
|
2329
|
-
async function getDistinctRows() {
|
|
2330
|
-
const rows = await db.orderLine.distinct({
|
|
2331
|
-
orderId: x => x.orderId
|
|
2332
|
-
});
|
|
2333
|
-
}
|
|
2334
|
-
```
|
|
2335
|
-
|
|
2336
2319
|
__Count__
|
|
2337
2320
|
For convenience, you can use the <i>count</i> directly on the table instead of using the aggregated query syntax.
|
|
2338
2321
|
```javascript
|
|
@@ -2442,7 +2425,7 @@ COMMIT
|
|
|
2442
2425
|
<ul>
|
|
2443
2426
|
<li><strong>It is not about migrations</strong> <p>The allure of ORMs handling SQL migrations is undeniably attractive and sweet. However, this sweetness can become painful. Auto-generated migration scripts might not capture all nuances. Using dedicated migration tools separate from the ORM or manually managing migrations might be the less painful route in the long run. Orange aim for database agnosticism. And when you're dealing with migrations, you might want to use features specific to a database platform. However, I might consider adding support for (non-auto-generated) migrations at a later point. But for now, it is not on the roadmap.</p></li>
|
|
2444
2427
|
<li><strong>It is not about NoSql databases</strong> <p>Applying ORMs to NoSQL, which inherently diverges from the relational model, can lead to data representation mismatches and a loss of specialized NoSQL features. Moreover, the added ORM layer can introduce performance inefficiencies, complicate debugging, and increase maintenance concerns. Given the unique capabilities of each NoSQL system, crafting custom data access solutions tailored to specific needs often provides better results than a generalized ORM approach.</p></li>
|
|
2445
|
-
<li><strong>It is not about
|
|
2428
|
+
<li><strong>It is not about GraphQL</strong> <p>Orange, already supports remote data operations via HTTP, eliminating the primary need for integrating GraphQL. Orange's built-in safety mechanisms and tailored optimization layers ensure secure and efficient data operations, which might be compromised by adding GraphQL. Furthermore, Orange's inherent expressivity and powerful querying capabilities could be overshadowed by the introduction of GraphQL. Integrating GraphQL could introduce unnecessary complexity, potential performance overhead, and maintenance challenges, especially as both systems continue to evolve. Therefore, considering Orange's robust features and design, supporting GraphQL might not offer sufficient advantages to warrant the associated complications. </p></li>
|
|
2446
2429
|
</ul>
|
|
2447
2430
|
|
|
2448
2431
|
</p>
|