Skip to content

Commit cecfda0

Browse files
committed
Documented cloudflare D1
1 parent a71b3d5 commit cecfda0

File tree

3 files changed

+411
-359
lines changed

3 files changed

+411
-359
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ The ultimate Object Relational Mapper for Node.js and Typescript, offering seaml
2929
✅ MySQL
3030
✅ Oracle
3131
✅ SAP ASE
32-
✅ SQLite
32+
✅ SQLite
33+
✅ Cloudflare D1
3334

3435

3536
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,22 @@ import map from './map';
319320

320321
const db = map.http('http://localhost:3000/orange');
321322
```
323+
__Cloudflare D1__
324+
<sub>📄 wrangler.toml</sub>
325+
```toml
326+
# Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
327+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
328+
[[d1_databases]]
329+
binding = "DB"
330+
database_name = "<your-name-for-the-database>"
331+
database_id = "<your-guid-for-the-database>"
332+
```
333+
334+
```javascript
335+
import map from './map';
336+
// Must match the binding name in wrangler.toml
337+
const db = map.d1(env.DB);
338+
```
322339
__MySQL__
323340
```bash
324341
$ npm install mysql2
@@ -1580,6 +1597,8 @@ async function getRows() {
15801597
Within the transaction, a customer is retrieved and its balance updated using the tx object to ensure operations are transactional.
15811598
An error is deliberately thrown to demonstrate a rollback, ensuring all previous changes within the transaction are reverted.
15821599
Always use the provided tx object for operations within the transaction to maintain data integrity.</p>
1600+
<p>(NOTE: Transactions are not supported for Cloudflare D1)</p>
1601+
15831602
15841603
```javascript
15851604
import map from './map';
@@ -1597,6 +1616,7 @@ async function execute() {
15971616
}
15981617

15991618
```
1619+
16001620
</details>
16011621
16021622
<details><summary><strong>Data types</strong></summary>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "orange-orm",
3-
"version": "4.5.0-beta.1",
3+
"version": "4.5.0-beta.2",
44
"main": "./src/index.js",
55
"browser": "./src/client/index.mjs",
66
"bin": {

0 commit comments

Comments
 (0)