Skip to content

Commit b0c5113

Browse files
committed
docs: Add docs about nesting
1 parent fda5667 commit b0c5113

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

docs/usage/nested.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: Nested Queries
3+
parent: Usage
4+
nav_order: 4
5+
---
6+
Starting from `0.2.0`, queries can be nested infinitely.
7+
8+
The following configuration is used in the [demo](../demo/):
9+
10+
```yaml
11+
sqlite:
12+
- data: regions
13+
file: *db
14+
query: |
15+
SELECT RegionID, RegionDescription FROM Regions
16+
ORDER BY RegionID
17+
18+
- data: regions.territories
19+
file: *db
20+
query: |
21+
SELECT TerritoryID, TerritoryDescription FROM Territories
22+
WHERE RegionID = :RegionID
23+
ORDER BY TerritoryDescription
24+
25+
- data: regions.territories.EmployeeIDs
26+
file: *db
27+
query: |
28+
SELECT T.EmployeeID as EmployeeID, FirstName,LastName
29+
FROM EmployeeTerritories T,Employees
30+
WHERE T.TerritoryID = :TerritoryID
31+
AND T.EmployeeID = Employees.EmployeeID
32+
```
33+
34+
The first query generates `site.data.regions` as a list. The second query
35+
sets territories inside each of the regions, and the third query
36+
sets the list of employees inside each territory.
37+
38+
{: .note }
39+
> Per Page Query
40+
>
41+
> On the Demo website, you can see the result at
42+
> [the regions page](https://northwind.captnemo.in/regions.html)
43+
> where each region is broken into territories, with the name
44+
> of the employee under each region.

lib/jekyll-sqlite/generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def generate_data_from_config(root, config)
7979
key = config["data"]
8080
query = config["query"]
8181
file = config["file"]
82-
82+
8383
db = get_database(file)
8484
db.results_as_hash = config.fetch("results_as_hash", true)
8585
path_segments = key.split(".")

0 commit comments

Comments
 (0)