Skip to content

Commit

Permalink
readme sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
lroal committed Mar 25, 2024
1 parent e2c9712 commit df76239
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
41 changes: 20 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,26 @@ async function getRows() {
</details>
<details id="filtering-relations"><summary><strong>Relation filters</strong></summary>
<p>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.</p>
```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
});
}
```
</details>
<details id="basic-filters"><summary><strong>Basic filters</strong></summary>
<p>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 <i>any</i> and <i>exists</i> 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.</p>
Expand Down Expand Up @@ -1384,27 +1404,6 @@ async function getRows() {
</details>
<details id="filtering-relations"><summary><strong>Relation filters</strong></summary>
<p>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.</p>
```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
});
}
```
</details>
<details><summary><strong>Transactions</strong></summary>
<p>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.
Expand Down
1 change: 1 addition & 0 deletions src/map.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ type MappedDbInstance<T> = {
transaction(
fn: (db: MappedDbInstance<T>) => Promise<unknown>
): Promise<void>;
saveChanges(arraysOrRow: {saveChanges(): Promise<void>}): Promise<void>;
express(): import('express').RequestHandler;
express(config: ExpressConfig<T>): import('express').RequestHandler;
readonly metaData: DbConcurrency<T>;
Expand Down

0 comments on commit df76239

Please sign in to comment.