orange-orm 4.7.0-beta.1 → 4.7.0-beta.3

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
@@ -286,6 +286,10 @@ npm install sqlite3
286
286
  ```javascript
287
287
  import map from './map';
288
288
  const db = map.sqlite('demo.db');
289
+ // … use the database …
290
+
291
+ // IMPORTANT for serverless functions:
292
+ await db.close(); // closes the client connection
289
293
  ```
290
294
  __With connection pool__
291
295
  ```bash
@@ -294,7 +298,14 @@ npm install sqlite3
294
298
  ```javascript
295
299
  import map from './map';
296
300
  const db = map.sqlite('demo.db', { size: 10 });
301
+ // … use the pool …
302
+
303
+ // IMPORTANT for serverless functions:
304
+ await pool.close(); // closes all pooled connections
297
305
  ```
306
+ __Why close ?__
307
+ In serverless environments (e.g. AWS Lambda, Vercel, Cloudflare Workers) execution contexts are frequently frozen and resumed. Explicitly closing the client or pool ensures that file handles are released promptly and prevents “database locked” errors between invocations.
308
+
298
309
  __From the browser__
299
310
  You can securely use Orange from the browser by utilizing the Express plugin, which serves to safeguard sensitive database credentials from exposure at the client level. This technique bypasses the need to transmit raw SQL queries directly from the client to the server. Instead, it logs method calls initiated by the client, which are later replayed and authenticated on the server. This not only reinforces security by preventing the disclosure of raw SQL queries on the client side but also facilitates a smoother operation. Essentially, this method mirrors a traditional REST API, augmented with advanced TypeScript tooling for enhanced functionality. You can read more about it in the section called [In the browser](#user-content-in-the-browser)
300
311
  <sub>📄 server.ts</sub>