datanotes 2.0.1 → 3.0.0
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/NOTICE +9 -0
- package/README.md +207 -28
- package/SECURITY.md +92 -45
- package/dist/THIRD-PARTY-NOTICES.txt +682 -0
- package/dist/api/catalog.d.cts +69 -0
- package/dist/api/catalog.d.ts +50 -2
- package/dist/api/cli-options.d.cts +39 -0
- package/dist/api/cli-options.d.ts +39 -0
- package/dist/api/client.d.cts +89 -0
- package/dist/api/client.d.ts +19 -30
- package/dist/api/docs.d.cts +211 -0
- package/dist/api/docs.d.ts +211 -0
- package/dist/api/guidance.d.cts +81 -0
- package/dist/api/guidance.d.ts +81 -0
- package/dist/api/index.cjs +6610 -2247
- package/dist/api/index.d.cts +13 -0
- package/dist/api/index.d.ts +10 -7
- package/dist/api/index.js +6610 -2247
- package/dist/api/local.cjs +118 -6
- package/dist/api/local.d.cts +95 -0
- package/dist/api/local.d.ts +70 -6
- package/dist/api/local.js +104 -6
- package/dist/api/mcp.cjs +17384 -0
- package/dist/api/mcp.d.cts +108 -0
- package/dist/api/mcp.d.ts +108 -0
- package/dist/api/mcp.js +17334 -0
- package/dist/api/otlp.d.cts +65 -0
- package/dist/api/redact.d.cts +17 -0
- package/dist/api/redact.d.ts +17 -0
- package/dist/api/requests.d.cts +26 -0
- package/dist/api/requests.d.ts +14 -16
- package/dist/api/results.d.cts +16 -0
- package/dist/api/results.d.ts +2 -1
- package/dist/api/tokens.d.cts +7 -0
- package/dist/datanotes.cjs +62511 -28069
- package/dist/docs/administration/configuration.md +59 -0
- package/dist/docs/administration/docker.md +80 -0
- package/dist/docs/administration/git-sync.md +71 -0
- package/dist/docs/administration/limits.md +69 -0
- package/dist/docs/administration/run-the-service.md +219 -0
- package/dist/docs/administration/status.md +61 -0
- package/dist/docs/administration/use-with-obsidian.md +75 -0
- package/dist/docs/api/operations/add_column.md +49 -0
- package/dist/docs/api/operations/add_constraint.md +55 -0
- package/dist/docs/api/operations/adopt_rows.md +50 -0
- package/dist/docs/api/operations/align_relations.md +41 -0
- package/dist/docs/api/operations/alter_column.md +46 -0
- package/dist/docs/api/operations/alter_table.md +67 -0
- package/dist/docs/api/operations/batch.md +48 -0
- package/dist/docs/api/operations/changes_stream.md +28 -0
- package/dist/docs/api/operations/check_table.md +29 -0
- package/dist/docs/api/operations/clone_table.md +48 -0
- package/dist/docs/api/operations/comment_on.md +42 -0
- package/dist/docs/api/operations/configure_database.md +52 -0
- package/dist/docs/api/operations/create_table.md +78 -0
- package/dist/docs/api/operations/create_view.md +54 -0
- package/dist/docs/api/operations/create_webhook.md +37 -0
- package/dist/docs/api/operations/define_base.md +52 -0
- package/dist/docs/api/operations/delete_rows.md +43 -0
- package/dist/docs/api/operations/delete_webhook.md +31 -0
- package/dist/docs/api/operations/describe_database.md +30 -0
- package/dist/docs/api/operations/describe_history.md +40 -0
- package/dist/docs/api/operations/describe_semantic_index.md +24 -0
- package/dist/docs/api/operations/describe_table.md +38 -0
- package/dist/docs/api/operations/docs.md +13 -0
- package/dist/docs/api/operations/drop_column.md +41 -0
- package/dist/docs/api/operations/drop_constraint.md +39 -0
- package/dist/docs/api/operations/drop_table.md +43 -0
- package/dist/docs/api/operations/drop_view.md +38 -0
- package/dist/docs/api/operations/engine_status.md +23 -0
- package/dist/docs/api/operations/graph_neighbors.md +32 -0
- package/dist/docs/api/operations/graph_path.md +32 -0
- package/dist/docs/api/operations/graph_traverse.md +43 -0
- package/dist/docs/api/operations/identify_session.md +24 -0
- package/dist/docs/api/operations/infer_table.md +43 -0
- package/dist/docs/api/operations/insert_row.md +48 -0
- package/dist/docs/api/operations/list_changes.md +35 -0
- package/dist/docs/api/operations/list_folder.md +28 -0
- package/dist/docs/api/operations/list_link_targets.md +44 -0
- package/dist/docs/api/operations/list_migrations.md +35 -0
- package/dist/docs/api/operations/list_tables.md +32 -0
- package/dist/docs/api/operations/list_webhooks.md +23 -0
- package/dist/docs/api/operations/manual_index.md +14 -0
- package/dist/docs/api/operations/manual_page.md +22 -0
- package/dist/docs/api/operations/merge_rows.md +44 -0
- package/dist/docs/api/operations/move_rows.md +52 -0
- package/dist/docs/api/operations/openapi.md +13 -0
- package/dist/docs/api/operations/openapi_post.md +20 -0
- package/dist/docs/api/operations/read_note.md +29 -0
- package/dist/docs/api/operations/recompute_columns.md +44 -0
- package/dist/docs/api/operations/record_tool_call.md +36 -0
- package/dist/docs/api/operations/rename_column.md +44 -0
- package/dist/docs/api/operations/rename_value.md +45 -0
- package/dist/docs/api/operations/restore_database.md +51 -0
- package/dist/docs/api/operations/restore_table.md +46 -0
- package/dist/docs/api/operations/search_notes.md +28 -0
- package/dist/docs/api/operations/select_rows.md +61 -0
- package/dist/docs/api/operations/semantic_search.md +34 -0
- package/dist/docs/api/operations/semantic_search_docs.md +26 -0
- package/dist/docs/api/operations/set_table_bases.md +44 -0
- package/dist/docs/api/operations/status.md +13 -0
- package/dist/docs/api/operations/stop_engine.md +23 -0
- package/dist/docs/api/operations/sync_semantic_index.md +33 -0
- package/dist/docs/api/operations/table_changes.md +31 -0
- package/dist/docs/api/operations/tags/auxiliary.md +14 -0
- package/dist/docs/api/operations/tags/change-feed.md +8 -0
- package/dist/docs/api/operations/tags/history.md +17 -0
- package/dist/docs/api/operations/tags/queries.md +15 -0
- package/dist/docs/api/operations/tags/rows-dml.md +16 -0
- package/dist/docs/api/operations/tags/schema-ddl.md +22 -0
- package/dist/docs/api/operations/tags/service.md +15 -0
- package/dist/docs/api/operations/tags/tokens.md +13 -0
- package/dist/docs/api/operations/tokens_create.md +34 -0
- package/dist/docs/api/operations/tokens_delete.md +29 -0
- package/dist/docs/api/operations/tokens_list.md +21 -0
- package/dist/docs/api/operations/tokens_me.md +20 -0
- package/dist/docs/api/operations/tokens_rotate.md +29 -0
- package/dist/docs/api/operations/tokens_update.md +34 -0
- package/dist/docs/api/operations/undo_migration.md +46 -0
- package/dist/docs/api/operations/update_row.md +60 -0
- package/dist/docs/api/operations/update_rows.md +46 -0
- package/dist/docs/api/operations/vacuum_table.md +37 -0
- package/dist/docs/api.md +135 -0
- package/dist/docs/develop/build-an-app.md +320 -0
- package/dist/docs/develop/build-on-datanotes.md +138 -0
- package/dist/docs/develop/change-feed-and-webhooks.md +70 -0
- package/dist/docs/develop/client.md +116 -0
- package/dist/docs/develop/concurrency.md +153 -0
- package/dist/docs/develop/http-api.md +79 -0
- package/dist/docs/develop/telemetry.md +86 -0
- package/dist/docs/guides/agents/docs-offline.md +99 -0
- package/dist/docs/guides/agents/how-agents-use-datanotes.md +124 -0
- package/dist/docs/guides/agents/prompts.md +495 -0
- package/dist/docs/guides/agents/reading-errors.md +112 -0
- package/dist/docs/guides/data-quality/check-constraints.md +379 -0
- package/dist/docs/guides/data-quality/check-table.md +63 -0
- package/dist/docs/guides/data-quality/hand-edits.md +507 -0
- package/dist/docs/guides/data-quality/sync-between-devices.md +51 -0
- package/dist/docs/guides/data-quality/validation.md +90 -0
- package/dist/docs/guides/database-objects/bases.md +480 -0
- package/dist/docs/guides/database-objects/catalogs-and-schemas.md +897 -0
- package/dist/docs/guides/database-objects/columns.md +1332 -0
- package/dist/docs/guides/database-objects/relations.md +1454 -0
- package/dist/docs/guides/database-objects/tables.md +1404 -0
- package/dist/docs/guides/database-objects/views.md +1003 -0
- package/dist/docs/guides/history/back-up.md +195 -0
- package/dist/docs/guides/history/change-data-feed.md +247 -0
- package/dist/docs/guides/history/journal-and-undo.md +262 -0
- package/dist/docs/guides/history/restore.md +341 -0
- package/dist/docs/guides/history/table-history.md +657 -0
- package/dist/docs/guides/history/vacuum.md +35 -0
- package/dist/docs/guides/read-and-write/automatic-links.md +768 -0
- package/dist/docs/guides/read-and-write/batch.md +139 -0
- package/dist/docs/guides/read-and-write/import-notes.md +896 -0
- package/dist/docs/guides/read-and-write/joins-and-aggregates.md +251 -0
- package/dist/docs/guides/read-and-write/read-and-filter.md +536 -0
- package/dist/docs/guides/read-and-write/write-rows.md +573 -0
- package/dist/docs/guides/search/link-graph.md +146 -0
- package/dist/docs/guides/search/semantic.md +133 -0
- package/dist/docs/guides/search/text.md +142 -0
- package/dist/docs/guides/security/security-model.md +110 -0
- package/dist/docs/guides/security/tokens.md +60 -0
- package/dist/docs/guides/security/who-did-what.md +42 -0
- package/dist/docs/index.md +113 -0
- package/dist/docs/llms.txt +33 -0
- package/dist/docs/reference/cli.md +136 -0
- package/dist/docs/reference/compatibility.md +63 -0
- package/dist/docs/reference/errors.md +72 -0
- package/dist/docs/reference/glossary.md +161 -0
- package/dist/docs/reference/operations/auxiliary.md +116 -0
- package/dist/docs/reference/operations/history.md +168 -0
- package/dist/docs/reference/operations/queries.md +169 -0
- package/dist/docs/reference/operations/rows.md +185 -0
- package/dist/docs/reference/operations/schema.md +316 -0
- package/dist/docs/reference/operations.md +96 -0
- package/dist/docs/reference/settings.md +31 -0
- package/dist/docs/release-notes.md +67 -0
- package/dist/docs/start/connect-agents.md +204 -0
- package/dist/docs/start/how-it-works.md +317 -0
- package/dist/docs/start/quick-start.md +126 -0
- package/package.json +58 -14
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
# Joins and aggregates
|
|
2
|
+
|
|
3
|
+
> Group rows and compute totals, join tables on links or on computed keys, and count rows across links.
|
|
4
|
+
|
|
5
|
+
`select_rows` groups rows and computes totals with `group_by` and aggregates, and joins tables on links or on matching values. The examples query a diary of classic films with its cast and viewings.
|
|
6
|
+
|
|
7
|
+
## Group rows and compute totals
|
|
8
|
+
|
|
9
|
+
`group_by` groups the rows, and `aggregates` computes one value per group. These are the aggregates:
|
|
10
|
+
|
|
11
|
+
* **`count`**: the rows in the group
|
|
12
|
+
* **`count:col`**: the rows where the column has a value
|
|
13
|
+
* **`sum:col`**, **`avg:col`**, **`min:col`** and **`max:col`**: the total, average, smallest and largest value of the column
|
|
14
|
+
|
|
15
|
+
**`select_rows`**
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"table": "film",
|
|
20
|
+
"group_by": "status",
|
|
21
|
+
"aggregates": {
|
|
22
|
+
"films": "count",
|
|
23
|
+
"rated": "count:rating",
|
|
24
|
+
"minutes": "sum:minutes",
|
|
25
|
+
"average": "avg:minutes",
|
|
26
|
+
"longest": "max:minutes"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Answer:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"table": "main.public.film",
|
|
36
|
+
"total": 2,
|
|
37
|
+
"rows": [
|
|
38
|
+
{
|
|
39
|
+
"status": "to watch",
|
|
40
|
+
"films": 2,
|
|
41
|
+
"rated": 0,
|
|
42
|
+
"minutes": 228,
|
|
43
|
+
"average": 114,
|
|
44
|
+
"longest": 153
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"status": "watched",
|
|
48
|
+
"films": 6,
|
|
49
|
+
"rated": 6,
|
|
50
|
+
"minutes": 535,
|
|
51
|
+
"average": 89.166667,
|
|
52
|
+
"longest": 113
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
A link column makes one group per linked note. These are the viewings per film:
|
|
59
|
+
|
|
60
|
+
**`select_rows`**
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{ "table": "watch", "group_by": "film", "aggregates": { "viewings": "count" } }
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Answer:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"table": "main.public.watch",
|
|
71
|
+
"total": 6,
|
|
72
|
+
"rows": [
|
|
73
|
+
{ "film": "[[Charade]]", "viewings": 1 },
|
|
74
|
+
{ "film": "[[His Girl Friday]]", "viewings": 1 },
|
|
75
|
+
{ "film": "[[Night of the Living Dead]]", "viewings": 1 },
|
|
76
|
+
{ "film": "[[Nosferatu]]", "viewings": 1 },
|
|
77
|
+
{ "film": "[[Sherlock Jr.]]", "viewings": 1 },
|
|
78
|
+
{ "film": "[[The Gold Rush]]", "viewings": 2 }
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`date(col)` groups a date-time column by day. These are the viewings per day over the last week:
|
|
84
|
+
|
|
85
|
+
**`select_rows`**
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"table": "watch",
|
|
90
|
+
"group_by": "date(occurred_at)",
|
|
91
|
+
"aggregates": { "viewings": "count" },
|
|
92
|
+
"where": { "occurred_at": { "gte": "{today-7d}" } }
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Answer:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"table": "main.public.watch",
|
|
101
|
+
"total": 3,
|
|
102
|
+
"rows": [
|
|
103
|
+
{ "date(occurred_at)": "2026-10-07", "viewings": 1 },
|
|
104
|
+
{ "date(occurred_at)": "2026-10-10", "viewings": 1 },
|
|
105
|
+
{ "date(occurred_at)": "2026-10-11", "viewings": 1 }
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Join rows on a computed key
|
|
111
|
+
|
|
112
|
+
`join` attaches to each row the rows of another table whose values match, and `on` maps a column of this table to a column of the other. `date(col)` matches a date-time by its day, optionally shifted by a number of days. Here each film watched in the last three days gets the viewing of its `watched_on` day. The viewing tells you where you saw the film and who came along.
|
|
113
|
+
|
|
114
|
+
**`select_rows`**
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"table": "film",
|
|
119
|
+
"columns": ["title", "watched_on"],
|
|
120
|
+
"where": { "watched_on": { "gte": "{today-3d}" } },
|
|
121
|
+
"join": {
|
|
122
|
+
"table": "watch",
|
|
123
|
+
"on": { "watched_on": "date(occurred_at)" },
|
|
124
|
+
"as": "viewing",
|
|
125
|
+
"type": "inner",
|
|
126
|
+
"columns": ["where", "with"]
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Answer:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"table": "main.public.film",
|
|
136
|
+
"total": 2,
|
|
137
|
+
"rows": [
|
|
138
|
+
{
|
|
139
|
+
"path": "datanotes/main/public/film/Night of the Living Dead.md",
|
|
140
|
+
"title": "Night of the Living Dead",
|
|
141
|
+
"watched_on": "2026-10-11",
|
|
142
|
+
"viewing": [
|
|
143
|
+
{
|
|
144
|
+
"path": "datanotes/main/public/watch/2026-10-11T2200.md",
|
|
145
|
+
"where": "cinema",
|
|
146
|
+
"with": "Oscar"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"path": "datanotes/main/public/film/The Gold Rush.md",
|
|
152
|
+
"title": "The Gold Rush",
|
|
153
|
+
"watched_on": "2026-10-10",
|
|
154
|
+
"viewing": [
|
|
155
|
+
{
|
|
156
|
+
"path": "datanotes/main/public/watch/2026-10-10T2030.md",
|
|
157
|
+
"where": "home",
|
|
158
|
+
"with": "my sister"
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Join two tables on matching values
|
|
167
|
+
|
|
168
|
+
`join` attaches the rows of another table whose columns match. Here each film gets its viewings: the viewing’s `film` link matches the film’s own link, `file_link`.
|
|
169
|
+
|
|
170
|
+
**`select_rows`**
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"table": "film",
|
|
175
|
+
"columns": ["title"],
|
|
176
|
+
"join": {
|
|
177
|
+
"table": "watch",
|
|
178
|
+
"on": { "file_link": "film" },
|
|
179
|
+
"as": "viewings",
|
|
180
|
+
"type": "left",
|
|
181
|
+
"columns": ["where", "occurred_at"]
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Answer:
|
|
187
|
+
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"table": "main.public.film",
|
|
191
|
+
"total": 3,
|
|
192
|
+
"rows": [
|
|
193
|
+
{
|
|
194
|
+
"path": "datanotes/main/public/film/Charade.md",
|
|
195
|
+
"title": "Charade",
|
|
196
|
+
"viewings": [
|
|
197
|
+
{
|
|
198
|
+
"path": "datanotes/main/public/watch/2026-09-26T2130.md",
|
|
199
|
+
"where": "home",
|
|
200
|
+
"occurred_at": "2026-09-26T21:30"
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"path": "datanotes/main/public/film/His Girl Friday.md",
|
|
206
|
+
"title": "His Girl Friday",
|
|
207
|
+
"viewings": [
|
|
208
|
+
{
|
|
209
|
+
"path": "datanotes/main/public/watch/2026-03-14T2030.md",
|
|
210
|
+
"where": "cinema",
|
|
211
|
+
"occurred_at": "2026-03-14T20:30"
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"path": "datanotes/main/public/film/Night of the Living Dead.md",
|
|
217
|
+
"title": "Night of the Living Dead",
|
|
218
|
+
"viewings": []
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Count rows across a list of links
|
|
225
|
+
|
|
226
|
+
`group_by` on a list column counts each item once, so a film with two actors counts for both, and Cary Grant’s group holds two films. Night of the Living Dead has no cast here, so it falls in the `null` group.
|
|
227
|
+
|
|
228
|
+
**`select_rows`**
|
|
229
|
+
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"table": "film",
|
|
233
|
+
"group_by": "cast",
|
|
234
|
+
"aggregates": { "films": "count", "minutes": "sum:minutes" }
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Answer:
|
|
239
|
+
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"table": "main.public.film",
|
|
243
|
+
"total": 4,
|
|
244
|
+
"rows": [
|
|
245
|
+
{ "cast": "[[Audrey Hepburn]]", "films": 1, "minutes": 113 },
|
|
246
|
+
{ "cast": "[[Cary Grant]]", "films": 2, "minutes": 205 },
|
|
247
|
+
{ "cast": "[[Rosalind Russell]]", "films": 1, "minutes": 92 },
|
|
248
|
+
{ "cast": null, "films": 1, "minutes": 96 }
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
```
|