datanotes 2.0.0 → 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 +62911 -28409
- 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 +59 -14
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
# Bases
|
|
2
|
+
|
|
3
|
+
> Share columns between tables with bases, change a base and every table that extends it, and build bases on bases.
|
|
4
|
+
|
|
5
|
+
A base is a named set of columns that tables inherit, like a parent class. One query reads every table that extends a base, on the base’s columns, and a new table that extends it appears in the results without changes to any view.
|
|
6
|
+
|
|
7
|
+
The examples on this page keep a diary of classic films in its own catalog, `diary`.
|
|
8
|
+
|
|
9
|
+
## Share columns between tables with bases
|
|
10
|
+
|
|
11
|
+
A base is a named set of columns that tables inherit, like a parent class. Every table that extends `entry` gets `added_on` and `note` with the same meaning. `select_rows` on `base:entry` reads all those tables at once, here films and actors.
|
|
12
|
+
|
|
13
|
+
**`define_base`**
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"name": "entry",
|
|
18
|
+
"description": "A note of the film diary",
|
|
19
|
+
"columns": [
|
|
20
|
+
{ "name": "added_on", "type": "date", "description": "When I added it to the diary" },
|
|
21
|
+
{ "name": "note", "type": "string", "description": "Free text" }
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Answer:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"ok": true,
|
|
31
|
+
"op": "define_base",
|
|
32
|
+
"planned_texts": ["datanotes/metastore.yaml"],
|
|
33
|
+
"migration_id": "20261012T072003-define_base-create-base-entry"
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**`set_table_bases`**
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{ "table": "film", "bases": ["entry"] }
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Answer:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"ok": true,
|
|
48
|
+
"op": "set_table_bases",
|
|
49
|
+
"planned_texts": ["datanotes/metastore.yaml"],
|
|
50
|
+
"commits": [
|
|
51
|
+
{ "table": "diary.classics.film", "version": 6, "operation": "SET TABLE BASES" }
|
|
52
|
+
],
|
|
53
|
+
"migration_id": "20261012T072003-set_table_bases-diary-classics-film-extends-en"
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**`create_table`**
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"catalog": "diary",
|
|
62
|
+
"schema": "classics",
|
|
63
|
+
"name": "actors",
|
|
64
|
+
"description": "Actors of the films in the diary",
|
|
65
|
+
"columns": [
|
|
66
|
+
{
|
|
67
|
+
"name": "name",
|
|
68
|
+
"type": "string",
|
|
69
|
+
"required": true,
|
|
70
|
+
"description": "The actor's name, as credited"
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"filename": "{name}"
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**`set_table_bases`**
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{ "table": "actors", "bases": ["entry"] }
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**`insert_row`**
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"table": "actors",
|
|
88
|
+
"values": {
|
|
89
|
+
"name": "Max Schreck",
|
|
90
|
+
"added_on": "2026-10-05",
|
|
91
|
+
"note": "The face of Nosferatu"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**`update_row`**
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"table": "film",
|
|
101
|
+
"path": "datanotes/diary/classics/film/Nosferatu.md",
|
|
102
|
+
"set": { "added_on": "2026-10-05" }
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**`select_rows`**
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{ "table": "base:entry", "order_by": "path" }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Answer:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"table": "base:entry",
|
|
117
|
+
"total": 2,
|
|
118
|
+
"rows": [
|
|
119
|
+
{
|
|
120
|
+
"path": "datanotes/diary/classics/actors/Max Schreck.md",
|
|
121
|
+
"id": "01a12efb-9be0-7a9c-8083-7efd16947e0f",
|
|
122
|
+
"added_on": "2026-10-05",
|
|
123
|
+
"note": "The face of Nosferatu",
|
|
124
|
+
"_source": "diary.classics.actors"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"path": "datanotes/diary/classics/film/Nosferatu.md",
|
|
128
|
+
"id": "01a12efb-9b66-77e4-b6ce-d40737b6f5ea",
|
|
129
|
+
"added_on": "2026-10-05",
|
|
130
|
+
"note": null,
|
|
131
|
+
"_source": "diary.classics.film"
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Change a base and every table that extends it
|
|
138
|
+
|
|
139
|
+
Replacing a base changes every table that extends it, in one operation. `rename_columns` renames a column on their rows. `define_base` refuses to drop a column unless `drop_columns` names it, and then the engine removes the column’s values from the rows too.
|
|
140
|
+
|
|
141
|
+
**`define_base`**
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"name": "entry",
|
|
146
|
+
"columns": [
|
|
147
|
+
{ "name": "added_on", "type": "date", "description": "When I added it to the diary" },
|
|
148
|
+
{ "name": "comment", "type": "string", "description": "Free text" }
|
|
149
|
+
],
|
|
150
|
+
"rename_columns": { "note": "comment" }
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Answer:
|
|
155
|
+
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"ok": true,
|
|
159
|
+
"op": "define_base",
|
|
160
|
+
"notes_changed": 1,
|
|
161
|
+
"planned_edits": [
|
|
162
|
+
{
|
|
163
|
+
"path": "datanotes/diary/classics/actors/Max Schreck.md",
|
|
164
|
+
"set": { "comment": "The face of Nosferatu" },
|
|
165
|
+
"remove": ["note"]
|
|
166
|
+
}
|
|
167
|
+
],
|
|
168
|
+
"planned_texts": ["datanotes/metastore.yaml"],
|
|
169
|
+
"commits": [
|
|
170
|
+
{ "table": "diary.classics.actors", "version": 3, "operation": "DEFINE BASE" }
|
|
171
|
+
],
|
|
172
|
+
"migration_id": "20261012T072003-define_base-alter-base-entry"
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**`select_rows`**
|
|
177
|
+
|
|
178
|
+
```json
|
|
179
|
+
{ "table": "actors", "columns": ["name", "comment"] }
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Answer:
|
|
183
|
+
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"table": "diary.classics.actors",
|
|
187
|
+
"total": 1,
|
|
188
|
+
"rows": [
|
|
189
|
+
{
|
|
190
|
+
"path": "datanotes/diary/classics/actors/Max Schreck.md",
|
|
191
|
+
"name": "Max Schreck",
|
|
192
|
+
"comment": "The face of Nosferatu"
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
`define_base` refuses a base without `comment` until the call says the values may go:
|
|
199
|
+
|
|
200
|
+
**`define_base`**
|
|
201
|
+
|
|
202
|
+
```json
|
|
203
|
+
{
|
|
204
|
+
"name": "entry",
|
|
205
|
+
"columns": [
|
|
206
|
+
{ "name": "added_on", "type": "date", "description": "When I added it to the diary" }
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Refused:
|
|
212
|
+
|
|
213
|
+
```text
|
|
214
|
+
base "entry" would lose column "comment": list it in drop_columns (its values are removed from the rows) or rename_columns
|
|
215
|
+
Hint: Check the arguments of define_base: name (string, required), columns (list of objects, required), bases (list of strings), description (string), rename_columns (object), drop_columns (list of strings), dry_run (boolean).
|
|
216
|
+
Docs: https://datanotes.dev/reference/operations/schema.md#define_base (offline: read_docs("reference/operations/schema#define_base"))
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**`define_base`**
|
|
220
|
+
|
|
221
|
+
```json
|
|
222
|
+
{
|
|
223
|
+
"name": "entry",
|
|
224
|
+
"columns": [
|
|
225
|
+
{ "name": "added_on", "type": "date", "description": "When I added it to the diary" }
|
|
226
|
+
],
|
|
227
|
+
"drop_columns": ["comment"]
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Answer:
|
|
232
|
+
|
|
233
|
+
```json
|
|
234
|
+
{
|
|
235
|
+
"ok": true,
|
|
236
|
+
"op": "define_base",
|
|
237
|
+
"notes_changed": 1,
|
|
238
|
+
"planned_edits": [
|
|
239
|
+
{
|
|
240
|
+
"path": "datanotes/diary/classics/actors/Max Schreck.md",
|
|
241
|
+
"set": {},
|
|
242
|
+
"remove": ["comment"]
|
|
243
|
+
}
|
|
244
|
+
],
|
|
245
|
+
"planned_texts": ["datanotes/metastore.yaml"],
|
|
246
|
+
"commits": [
|
|
247
|
+
{ "table": "diary.classics.actors", "version": 4, "operation": "DEFINE BASE" }
|
|
248
|
+
],
|
|
249
|
+
"migration_id": "20261012T072003-define_base-alter-base-entry-2"
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Build bases on bases and link a table to itself
|
|
254
|
+
|
|
255
|
+
`bases` builds a base on others. A table that extends `credited` gets `films`, plus `added_on` from `entry`, and `base:entry` still reads it. In a base, `ref: "self"` means the table that inherits it, so `tree` gives each table a `parent` link to its own rows.
|
|
256
|
+
|
|
257
|
+
**`define_base`**
|
|
258
|
+
|
|
259
|
+
```json
|
|
260
|
+
{
|
|
261
|
+
"name": "credited",
|
|
262
|
+
"bases": ["entry"],
|
|
263
|
+
"description": "Someone in the credits of a film",
|
|
264
|
+
"columns": [
|
|
265
|
+
{
|
|
266
|
+
"name": "films",
|
|
267
|
+
"type": "list",
|
|
268
|
+
"items": "link",
|
|
269
|
+
"ref": "diary.classics.film",
|
|
270
|
+
"description": "The films they’re credited in"
|
|
271
|
+
}
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Answer:
|
|
277
|
+
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"ok": true,
|
|
281
|
+
"op": "define_base",
|
|
282
|
+
"planned_texts": ["datanotes/metastore.yaml"],
|
|
283
|
+
"migration_id": "20261012T072003-define_base-create-base-credited"
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
**`set_table_bases`**
|
|
288
|
+
|
|
289
|
+
```json
|
|
290
|
+
{ "table": "actors", "bases": ["credited"] }
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Answer:
|
|
294
|
+
|
|
295
|
+
```json
|
|
296
|
+
{
|
|
297
|
+
"ok": true,
|
|
298
|
+
"op": "set_table_bases",
|
|
299
|
+
"planned_texts": ["datanotes/metastore.yaml"],
|
|
300
|
+
"commits": [
|
|
301
|
+
{ "table": "diary.classics.actors", "version": 5, "operation": "SET TABLE BASES" }
|
|
302
|
+
],
|
|
303
|
+
"migration_id": "20261012T072003-set_table_bases-diary-classics-actors-extends--2"
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
**`define_base`**
|
|
308
|
+
|
|
309
|
+
```json
|
|
310
|
+
{
|
|
311
|
+
"name": "tree",
|
|
312
|
+
"description": "Rows arranged in a tree",
|
|
313
|
+
"columns": [
|
|
314
|
+
{
|
|
315
|
+
"name": "parent",
|
|
316
|
+
"type": "link",
|
|
317
|
+
"ref": "self",
|
|
318
|
+
"hierarchy": true,
|
|
319
|
+
"description": "The row above this one"
|
|
320
|
+
}
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Answer:
|
|
326
|
+
|
|
327
|
+
```json
|
|
328
|
+
{
|
|
329
|
+
"ok": true,
|
|
330
|
+
"op": "define_base",
|
|
331
|
+
"planned_texts": ["datanotes/metastore.yaml"],
|
|
332
|
+
"migration_id": "20261012T072003-define_base-create-base-tree"
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**`create_table`**
|
|
337
|
+
|
|
338
|
+
```json
|
|
339
|
+
{
|
|
340
|
+
"catalog": "diary",
|
|
341
|
+
"schema": "classics",
|
|
342
|
+
"name": "genre",
|
|
343
|
+
"description": "Eras and genres of cinema, as a tree",
|
|
344
|
+
"columns": [
|
|
345
|
+
{
|
|
346
|
+
"name": "name",
|
|
347
|
+
"type": "string",
|
|
348
|
+
"required": true,
|
|
349
|
+
"description": "The name of the era or genre"
|
|
350
|
+
}
|
|
351
|
+
],
|
|
352
|
+
"filename": "{name}"
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
**`set_table_bases`**
|
|
357
|
+
|
|
358
|
+
```json
|
|
359
|
+
{ "table": "genre", "bases": ["tree"] }
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Answer:
|
|
363
|
+
|
|
364
|
+
```json
|
|
365
|
+
{
|
|
366
|
+
"ok": true,
|
|
367
|
+
"op": "set_table_bases",
|
|
368
|
+
"planned_texts": ["datanotes/metastore.yaml"],
|
|
369
|
+
"commits": [
|
|
370
|
+
{ "table": "diary.classics.genre", "version": 1, "operation": "SET TABLE BASES" }
|
|
371
|
+
],
|
|
372
|
+
"migration_id": "20261012T072003-set_table_bases-diary-classics-genre-extends-t"
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
**`insert_row`**
|
|
377
|
+
|
|
378
|
+
```json
|
|
379
|
+
{ "table": "genre", "values": { "name": "Cinema" } }
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
**`insert_row`**
|
|
383
|
+
|
|
384
|
+
```json
|
|
385
|
+
{ "table": "genre", "values": { "name": "Silent film", "parent": "[[Cinema]]" } }
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
In `genre`, `parent` links rows of `diary.classics.genre`:
|
|
389
|
+
|
|
390
|
+
**`describe_table`**
|
|
391
|
+
|
|
392
|
+
```json
|
|
393
|
+
{ "table": "genre" }
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
Answer:
|
|
397
|
+
|
|
398
|
+
```json
|
|
399
|
+
[
|
|
400
|
+
{ "name": "id", "type": "string" },
|
|
401
|
+
{ "name": "parent", "type": "link", "ref": "diary.classics.genre", "hierarchy": true },
|
|
402
|
+
{ "name": "name", "type": "string" }
|
|
403
|
+
]
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**`select_rows`**
|
|
407
|
+
|
|
408
|
+
```json
|
|
409
|
+
{ "table": "base:entry", "columns": ["added_on"], "order_by": "path" }
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
Answer:
|
|
413
|
+
|
|
414
|
+
```json
|
|
415
|
+
{
|
|
416
|
+
"table": "base:entry",
|
|
417
|
+
"total": 2,
|
|
418
|
+
"rows": [
|
|
419
|
+
{
|
|
420
|
+
"path": "datanotes/diary/classics/actors/Max Schreck.md",
|
|
421
|
+
"added_on": "2026-10-05",
|
|
422
|
+
"_source": "diary.classics.actors"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"path": "datanotes/diary/classics/film/Nosferatu.md",
|
|
426
|
+
"added_on": "2026-10-05",
|
|
427
|
+
"_source": "diary.classics.film"
|
|
428
|
+
}
|
|
429
|
+
]
|
|
430
|
+
}
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
`bases: []` removes a table’s bases. `set_table_bases` refuses it while rows hold values of the inherited columns, like the `parent` of Silent film:
|
|
434
|
+
|
|
435
|
+
**`set_table_bases`**
|
|
436
|
+
|
|
437
|
+
```json
|
|
438
|
+
{ "table": "genre", "bases": [] }
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
Refused:
|
|
442
|
+
|
|
443
|
+
```text
|
|
444
|
+
set_table_bases refused — nothing was written:
|
|
445
|
+
invalid datanotes/diary/classics/genre/Silent film.md: parent is not a column of table "genre"
|
|
446
|
+
Hint: Write only the table's columns: describe_table lists them. To keep a new front matter key, add_column first. Then call set_table_bases again (dry_run: true checks without writing).
|
|
447
|
+
Docs: https://datanotes.dev/guides/database-objects/tables.md#describe-a-table-before-writing-to-it (offline: read_docs("guides/database-objects/tables#describe-a-table-before-writing-to-it"))
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
On a table with no such values, `set_table_bases` removes the inherited columns from the definition. Here that table is an empty copy of `genre`:
|
|
451
|
+
|
|
452
|
+
**`clone_table`**
|
|
453
|
+
|
|
454
|
+
```json
|
|
455
|
+
{ "source": "genre", "target": "genre_draft", "copy_rows": false }
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
**`set_table_bases`**
|
|
459
|
+
|
|
460
|
+
```json
|
|
461
|
+
{ "table": "genre_draft", "bases": [] }
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
Answer:
|
|
465
|
+
|
|
466
|
+
```json
|
|
467
|
+
{
|
|
468
|
+
"ok": true,
|
|
469
|
+
"op": "set_table_bases",
|
|
470
|
+
"planned_texts": ["datanotes/metastore.yaml"],
|
|
471
|
+
"commits": [
|
|
472
|
+
{
|
|
473
|
+
"table": "diary.classics.genre_draft",
|
|
474
|
+
"version": 1,
|
|
475
|
+
"operation": "SET TABLE BASES"
|
|
476
|
+
}
|
|
477
|
+
],
|
|
478
|
+
"migration_id": "20261012T072004-set_table_bases-diary-classics-genre_draft-ext"
|
|
479
|
+
}
|
|
480
|
+
```
|