Skip to content

Commit f0ffc13

Browse files
committed
add schemas page, add all tables to ucast.as_sql
1 parent b6f31ca commit f0ffc13

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed

observablehq.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default {
2828
// footer: "Built with Observable.", // what to show in the footer (HTML)
2929
// sidebar: true, // whether to show the sidebar
3030
// toc: true, // whether to show the table of contents
31-
// pager: true, // whether to show previous & next links in the footer
31+
pager: false, // whether to show previous & next links in the footer
3232
// output: "dist", // path to the output root for build
3333
// search: true, // activate search
3434
// linkify: true, // convert URLs in Markdown to links

src/policies/filters.rego

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ include if {
1515
input.users.name == user
1616
}
1717

18-
conditions := data.convert.to_conditions(input, ["input.products", "input.users"], "data.filters.include")
18+
conditions := data.convert.to_conditions(
19+
input,
20+
["input.products", "input.users", "input.orders", "input.order_items"],
21+
"data.filters.include",
22+
)
1923

20-
query := ucast.as_sql(conditions, "postgres", {"users": {"$self": "u"}, "products": {"$self": "p"}})
24+
query := ucast.as_sql(
25+
conditions, "postgres",
26+
{
27+
"users": {"$self": "u"},
28+
"products": {"$self": "p"},
29+
"order_items": {"$self": "i"},
30+
"orders": {"$self": "o"},
31+
},
32+
)

src/schema.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
sql:
3+
orders: data/orders.db
4+
---
5+
# Schemas
6+
7+
```js
8+
const columns = ["column_name", "column_type"];
9+
```
10+
11+
```sql id=productsSchema
12+
describe orders.products
13+
```
14+
```sql id=usersSchema
15+
describe orders.users
16+
```
17+
```sql id=ordersSchema
18+
describe orders.orders
19+
```
20+
```sql id=orderItemsSchema
21+
describe orders.order_items
22+
```
23+
24+
<div class="grid grid-cols-2" style="grid-auto-rows: auto;">
25+
<div class="card">
26+
27+
`input.products`
28+
29+
${Inputs.table(productsSchema, { columns, select: false })}
30+
</div>
31+
<div class="card">
32+
33+
`input.users`
34+
35+
${Inputs.table(usersSchema, { columns, select: false })}
36+
</div>
37+
<div class="card">
38+
39+
`input.orders`
40+
41+
${Inputs.table(ordersSchema, { columns, select: false })}
42+
</div>
43+
<div class="card">
44+
45+
`input.order_items`
46+
47+
${Inputs.table(orderItemsSchema, { columns, select: false })}
48+
</div>
49+
</div>
50+

0 commit comments

Comments
 (0)