Relation filters offer a dynamic approach to selectively include or exclude related data based on specific criteria. In the provided example, all orders are retrieved, yet it filters the order lines to only include those that feature products with "broomstick" in their description. By setting deliveryAddress and customer to true, we also ensure the inclusion of these related entities in our result set.
+ +```javascript +import map from './map'; +const db = map.sqlite('demo.db'); + +getRows(); + +async function getRows() { + const orders = await db.order.getAll({ + lines: { + where: x => x.product.contains('broomstick') + }, + deliveryAddress: true, + customer: true + }); +} +``` +Filters are a versatile tool for both data retrieval and bulk deletions. They allow for precise targeting of records based on specific criteria and can be combined with operators like any and exists and even raw sql for more nuanced control. Filters can also be nested to any depth, enabling complex queries that can efficiently manage and manipulate large datasets. This dual functionality enhances database management by ensuring data relevance and optimizing performance.
@@ -1384,27 +1404,6 @@ async function getRows() {Relation filters offer a dynamic approach to selectively include or exclude related data based on specific criteria. In the provided example, all orders are retrieved, yet it filters the order lines to only include those that feature products with "broomstick" in their description. By setting deliveryAddress and customer to true, we also ensure the inclusion of these related entities in our result set.
- -```javascript -import map from './map'; -const db = map.sqlite('demo.db'); - -getRows(); - -async function getRows() { - const orders = await db.order.getAll({ - lines: { - where: x => x.product.contains('broomstick') - }, - deliveryAddress: true, - customer: true - }); -} -``` -We initiate a database transaction using db.transaction.
Within the transaction, a customer is retrieved and its balance updated using the tx object to ensure operations are transactional.
diff --git a/src/map.d.ts b/src/map.d.ts
index 24304a3e..e8fd9eb5 100644
--- a/src/map.d.ts
+++ b/src/map.d.ts
@@ -92,6 +92,7 @@ type MappedDbInstance