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.
Files changed (181) hide show
  1. package/NOTICE +9 -0
  2. package/README.md +207 -28
  3. package/SECURITY.md +92 -45
  4. package/dist/THIRD-PARTY-NOTICES.txt +682 -0
  5. package/dist/api/catalog.d.cts +69 -0
  6. package/dist/api/catalog.d.ts +50 -2
  7. package/dist/api/cli-options.d.cts +39 -0
  8. package/dist/api/cli-options.d.ts +39 -0
  9. package/dist/api/client.d.cts +89 -0
  10. package/dist/api/client.d.ts +19 -30
  11. package/dist/api/docs.d.cts +211 -0
  12. package/dist/api/docs.d.ts +211 -0
  13. package/dist/api/guidance.d.cts +81 -0
  14. package/dist/api/guidance.d.ts +81 -0
  15. package/dist/api/index.cjs +6610 -2247
  16. package/dist/api/index.d.cts +13 -0
  17. package/dist/api/index.d.ts +10 -7
  18. package/dist/api/index.js +6610 -2247
  19. package/dist/api/local.cjs +118 -6
  20. package/dist/api/local.d.cts +95 -0
  21. package/dist/api/local.d.ts +70 -6
  22. package/dist/api/local.js +104 -6
  23. package/dist/api/mcp.cjs +17384 -0
  24. package/dist/api/mcp.d.cts +108 -0
  25. package/dist/api/mcp.d.ts +108 -0
  26. package/dist/api/mcp.js +17334 -0
  27. package/dist/api/otlp.d.cts +65 -0
  28. package/dist/api/redact.d.cts +17 -0
  29. package/dist/api/redact.d.ts +17 -0
  30. package/dist/api/requests.d.cts +26 -0
  31. package/dist/api/requests.d.ts +14 -16
  32. package/dist/api/results.d.cts +16 -0
  33. package/dist/api/results.d.ts +2 -1
  34. package/dist/api/tokens.d.cts +7 -0
  35. package/dist/datanotes.cjs +62911 -28409
  36. package/dist/docs/administration/configuration.md +59 -0
  37. package/dist/docs/administration/docker.md +80 -0
  38. package/dist/docs/administration/git-sync.md +71 -0
  39. package/dist/docs/administration/limits.md +69 -0
  40. package/dist/docs/administration/run-the-service.md +219 -0
  41. package/dist/docs/administration/status.md +61 -0
  42. package/dist/docs/administration/use-with-obsidian.md +75 -0
  43. package/dist/docs/api/operations/add_column.md +49 -0
  44. package/dist/docs/api/operations/add_constraint.md +55 -0
  45. package/dist/docs/api/operations/adopt_rows.md +50 -0
  46. package/dist/docs/api/operations/align_relations.md +41 -0
  47. package/dist/docs/api/operations/alter_column.md +46 -0
  48. package/dist/docs/api/operations/alter_table.md +67 -0
  49. package/dist/docs/api/operations/batch.md +48 -0
  50. package/dist/docs/api/operations/changes_stream.md +28 -0
  51. package/dist/docs/api/operations/check_table.md +29 -0
  52. package/dist/docs/api/operations/clone_table.md +48 -0
  53. package/dist/docs/api/operations/comment_on.md +42 -0
  54. package/dist/docs/api/operations/configure_database.md +52 -0
  55. package/dist/docs/api/operations/create_table.md +78 -0
  56. package/dist/docs/api/operations/create_view.md +54 -0
  57. package/dist/docs/api/operations/create_webhook.md +37 -0
  58. package/dist/docs/api/operations/define_base.md +52 -0
  59. package/dist/docs/api/operations/delete_rows.md +43 -0
  60. package/dist/docs/api/operations/delete_webhook.md +31 -0
  61. package/dist/docs/api/operations/describe_database.md +30 -0
  62. package/dist/docs/api/operations/describe_history.md +40 -0
  63. package/dist/docs/api/operations/describe_semantic_index.md +24 -0
  64. package/dist/docs/api/operations/describe_table.md +38 -0
  65. package/dist/docs/api/operations/docs.md +13 -0
  66. package/dist/docs/api/operations/drop_column.md +41 -0
  67. package/dist/docs/api/operations/drop_constraint.md +39 -0
  68. package/dist/docs/api/operations/drop_table.md +43 -0
  69. package/dist/docs/api/operations/drop_view.md +38 -0
  70. package/dist/docs/api/operations/engine_status.md +23 -0
  71. package/dist/docs/api/operations/graph_neighbors.md +32 -0
  72. package/dist/docs/api/operations/graph_path.md +32 -0
  73. package/dist/docs/api/operations/graph_traverse.md +43 -0
  74. package/dist/docs/api/operations/identify_session.md +24 -0
  75. package/dist/docs/api/operations/infer_table.md +43 -0
  76. package/dist/docs/api/operations/insert_row.md +48 -0
  77. package/dist/docs/api/operations/list_changes.md +35 -0
  78. package/dist/docs/api/operations/list_folder.md +28 -0
  79. package/dist/docs/api/operations/list_link_targets.md +44 -0
  80. package/dist/docs/api/operations/list_migrations.md +35 -0
  81. package/dist/docs/api/operations/list_tables.md +32 -0
  82. package/dist/docs/api/operations/list_webhooks.md +23 -0
  83. package/dist/docs/api/operations/manual_index.md +14 -0
  84. package/dist/docs/api/operations/manual_page.md +22 -0
  85. package/dist/docs/api/operations/merge_rows.md +44 -0
  86. package/dist/docs/api/operations/move_rows.md +52 -0
  87. package/dist/docs/api/operations/openapi.md +13 -0
  88. package/dist/docs/api/operations/openapi_post.md +20 -0
  89. package/dist/docs/api/operations/read_note.md +29 -0
  90. package/dist/docs/api/operations/recompute_columns.md +44 -0
  91. package/dist/docs/api/operations/record_tool_call.md +36 -0
  92. package/dist/docs/api/operations/rename_column.md +44 -0
  93. package/dist/docs/api/operations/rename_value.md +45 -0
  94. package/dist/docs/api/operations/restore_database.md +51 -0
  95. package/dist/docs/api/operations/restore_table.md +46 -0
  96. package/dist/docs/api/operations/search_notes.md +28 -0
  97. package/dist/docs/api/operations/select_rows.md +61 -0
  98. package/dist/docs/api/operations/semantic_search.md +34 -0
  99. package/dist/docs/api/operations/semantic_search_docs.md +26 -0
  100. package/dist/docs/api/operations/set_table_bases.md +44 -0
  101. package/dist/docs/api/operations/status.md +13 -0
  102. package/dist/docs/api/operations/stop_engine.md +23 -0
  103. package/dist/docs/api/operations/sync_semantic_index.md +33 -0
  104. package/dist/docs/api/operations/table_changes.md +31 -0
  105. package/dist/docs/api/operations/tags/auxiliary.md +14 -0
  106. package/dist/docs/api/operations/tags/change-feed.md +8 -0
  107. package/dist/docs/api/operations/tags/history.md +17 -0
  108. package/dist/docs/api/operations/tags/queries.md +15 -0
  109. package/dist/docs/api/operations/tags/rows-dml.md +16 -0
  110. package/dist/docs/api/operations/tags/schema-ddl.md +22 -0
  111. package/dist/docs/api/operations/tags/service.md +15 -0
  112. package/dist/docs/api/operations/tags/tokens.md +13 -0
  113. package/dist/docs/api/operations/tokens_create.md +34 -0
  114. package/dist/docs/api/operations/tokens_delete.md +29 -0
  115. package/dist/docs/api/operations/tokens_list.md +21 -0
  116. package/dist/docs/api/operations/tokens_me.md +20 -0
  117. package/dist/docs/api/operations/tokens_rotate.md +29 -0
  118. package/dist/docs/api/operations/tokens_update.md +34 -0
  119. package/dist/docs/api/operations/undo_migration.md +46 -0
  120. package/dist/docs/api/operations/update_row.md +60 -0
  121. package/dist/docs/api/operations/update_rows.md +46 -0
  122. package/dist/docs/api/operations/vacuum_table.md +37 -0
  123. package/dist/docs/api.md +135 -0
  124. package/dist/docs/develop/build-an-app.md +320 -0
  125. package/dist/docs/develop/build-on-datanotes.md +138 -0
  126. package/dist/docs/develop/change-feed-and-webhooks.md +70 -0
  127. package/dist/docs/develop/client.md +116 -0
  128. package/dist/docs/develop/concurrency.md +153 -0
  129. package/dist/docs/develop/http-api.md +79 -0
  130. package/dist/docs/develop/telemetry.md +86 -0
  131. package/dist/docs/guides/agents/docs-offline.md +99 -0
  132. package/dist/docs/guides/agents/how-agents-use-datanotes.md +124 -0
  133. package/dist/docs/guides/agents/prompts.md +495 -0
  134. package/dist/docs/guides/agents/reading-errors.md +112 -0
  135. package/dist/docs/guides/data-quality/check-constraints.md +379 -0
  136. package/dist/docs/guides/data-quality/check-table.md +63 -0
  137. package/dist/docs/guides/data-quality/hand-edits.md +507 -0
  138. package/dist/docs/guides/data-quality/sync-between-devices.md +51 -0
  139. package/dist/docs/guides/data-quality/validation.md +90 -0
  140. package/dist/docs/guides/database-objects/bases.md +480 -0
  141. package/dist/docs/guides/database-objects/catalogs-and-schemas.md +897 -0
  142. package/dist/docs/guides/database-objects/columns.md +1332 -0
  143. package/dist/docs/guides/database-objects/relations.md +1454 -0
  144. package/dist/docs/guides/database-objects/tables.md +1404 -0
  145. package/dist/docs/guides/database-objects/views.md +1003 -0
  146. package/dist/docs/guides/history/back-up.md +195 -0
  147. package/dist/docs/guides/history/change-data-feed.md +247 -0
  148. package/dist/docs/guides/history/journal-and-undo.md +262 -0
  149. package/dist/docs/guides/history/restore.md +341 -0
  150. package/dist/docs/guides/history/table-history.md +657 -0
  151. package/dist/docs/guides/history/vacuum.md +35 -0
  152. package/dist/docs/guides/read-and-write/automatic-links.md +768 -0
  153. package/dist/docs/guides/read-and-write/batch.md +139 -0
  154. package/dist/docs/guides/read-and-write/import-notes.md +896 -0
  155. package/dist/docs/guides/read-and-write/joins-and-aggregates.md +251 -0
  156. package/dist/docs/guides/read-and-write/read-and-filter.md +536 -0
  157. package/dist/docs/guides/read-and-write/write-rows.md +573 -0
  158. package/dist/docs/guides/search/link-graph.md +146 -0
  159. package/dist/docs/guides/search/semantic.md +133 -0
  160. package/dist/docs/guides/search/text.md +142 -0
  161. package/dist/docs/guides/security/security-model.md +110 -0
  162. package/dist/docs/guides/security/tokens.md +60 -0
  163. package/dist/docs/guides/security/who-did-what.md +42 -0
  164. package/dist/docs/index.md +113 -0
  165. package/dist/docs/llms.txt +33 -0
  166. package/dist/docs/reference/cli.md +136 -0
  167. package/dist/docs/reference/compatibility.md +63 -0
  168. package/dist/docs/reference/errors.md +72 -0
  169. package/dist/docs/reference/glossary.md +161 -0
  170. package/dist/docs/reference/operations/auxiliary.md +116 -0
  171. package/dist/docs/reference/operations/history.md +168 -0
  172. package/dist/docs/reference/operations/queries.md +169 -0
  173. package/dist/docs/reference/operations/rows.md +185 -0
  174. package/dist/docs/reference/operations/schema.md +316 -0
  175. package/dist/docs/reference/operations.md +96 -0
  176. package/dist/docs/reference/settings.md +31 -0
  177. package/dist/docs/release-notes.md +67 -0
  178. package/dist/docs/start/connect-agents.md +204 -0
  179. package/dist/docs/start/how-it-works.md +317 -0
  180. package/dist/docs/start/quick-start.md +126 -0
  181. package/package.json +59 -14
@@ -0,0 +1,169 @@
1
+ # Query operations
2
+
3
+ > Operations that read rows and notes: select_rows, link targets, text and semantic search, the link graph.
4
+
5
+ Operations that read rows and notes: select_rows, link targets, text and semantic search, the link graph. The [overview](https://datanotes.dev/reference/operations/) lists every operation by kind. The MCP server, `datanotes mcp`, offers each operation as an MCP tool of the same name, and `engineTools()` of `datanotes/mcp` gives the same definitions to [your own MCP server](https://datanotes.dev/develop/build-on-datanotes/#build-your-own-mcp-server). `DatanotesClient.call(name, args)` runs one from code. Over HTTP each one is `POST /datanotes/operations/<name>/`, with its arguments as the JSON body: the [HTTP API reference](https://datanotes.dev/api/) lists them.
6
+
7
+ Every write is validated. Writes to rows and to the schema are journaled and undone with `undo_migration`; `configure_database`, the webhook operations, `vacuum_table` and `sync_semantic_index` are not journaled.
8
+
9
+ ## `select_rows`
10
+
11
+ **Select Rows** · read-only
12
+
13
+ Query rows: `{table, total, rows: [{path, ...}]}`. `table` may be a view, `system.information_schema.<catalogs|schemata|tables|columns|views|check_constraints>`, or `base:<name>` — every table that extends that base (e.g. `base:record`: all event-like tables), on the base’s columns, each row tagged `_source` with its table.
14
+
15
+ * `where`: as in update_rows; relative dates `"{today}"`, `"{today-7d}"`, `"{now-24h}"` (on a date column a date-time counts by its day); file columns `file_name`, `file_link`, `file_modified`, `file_backlink_count`.
16
+ * `columns`, `order_by` (`-col` descending), `limit` (default 100, max 1000), `offset`, `expand` (inline linked rows’ frontmatter), `include_body` (the note body as `body`).
17
+ * `join`: `{"table", "on": {"date(occurred_at)+1": "date(timestamp)"}, "as", "type": "inner"|"left", "columns", "where"}` — matches attached under `as`.
18
+ * `group_by` (column, `path` or `date(col)±n`; a list column counts once per item) + `aggregates` `{"n": "count", "kcal": "sum:meal.kcal"}` (count, count:col, sum, avg, min, max).
19
+ * `this_note`: vault path of the note the result is for: `{this.*}` tokens in a view’s query and in `where` read it (`{this.date}`, `{this.link}`, `{this.name}`, `{this.path}`); without it (or a front matter key the note lacks) a token stays as written and matches no row, whatever the operator (`within` included).
20
+ * Ordered enums compare by position. Time travel: `version` (of one table) or `timestamp`. With `timestamp` a join, a view, a union or `base:<name>` reads every table in it as of that time (`versions`: the version read of each); a table that did not exist then adds no rows to a union or base. `version` is refused where several tables are read; information_schema has no history. Views and bases keep today’s definition, and links followed by `where` (`project.kind`, `within`) or `expand` read the linked rows as they are now.
21
+
22
+ Examples: [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/), [Tables](https://datanotes.dev/guides/database-objects/tables/), [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Views](https://datanotes.dev/guides/database-objects/views/), [Bases](https://datanotes.dev/guides/database-objects/bases/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [Validation](https://datanotes.dev/guides/data-quality/validation/), [CHECK constraints](https://datanotes.dev/guides/data-quality/check-constraints/), [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/), [Read and filter rows](https://datanotes.dev/guides/read-and-write/read-and-filter/), [Joins and aggregates](https://datanotes.dev/guides/read-and-write/joins-and-aggregates/), [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/), [Batch writes](https://datanotes.dev/guides/read-and-write/batch/), [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/), [Journal and undo](https://datanotes.dev/guides/history/journal-and-undo/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/), [Restore a table or the database](https://datanotes.dev/guides/history/restore/).
23
+
24
+ | Parameter | Type | Required | Default | Description |
25
+ | -------------- | ------------ | ------------ | ------- | ----------- |
26
+ | `table` | string | yes | | |
27
+ | `columns` | string\[] \\ | null | | `null` |
28
+ | `where` | object \\ | null | | `null` |
29
+ | `order_by` | string \\ | string\[] \\ | null | |
30
+ | `limit` | integer \\ | null | | `null` |
31
+ | `offset` | integer \\ | null | | `null` |
32
+ | `expand` | string\[] \\ | null | | `null` |
33
+ | `join` | object \\ | null | | `null` |
34
+ | `group_by` | string \\ | string\[] \\ | null | |
35
+ | `aggregates` | object \\ | null | | `null` |
36
+ | `include_body` | boolean | | `false` | |
37
+ | `version` | integer \\ | null | | `null` |
38
+ | `timestamp` | string \\ | null | | `null` |
39
+ | `this_note` | string \\ | null | | `null` |
40
+
41
+ ## `list_link_targets`
42
+
43
+ **List Link Targets** · read-only
44
+
45
+ The rows a link column may point to, for one row: what an agent or a picker offers before writing the link. A link column can filter its targets:
46
+
47
+ * `ref_where`: a `where` filter every target must match (`{"kind": {"in": ["area", "project"]}}`).
48
+ * `ref_by`: a column of the row picks the targets’ level: `{"column": "kind", "map": {"area": null, "project": ["area"], "workstream": ["project"]}}`: a workstream’s parent must have kind project; `null` is a top level (the link must stay empty); any other level needs the link; a value missing from the map is refused. `levels: ["area", "project", "workstream"]` writes the same chain short (each level’s parent is the level before it). `target_column` reads another column of the target (default: the same name). describe_table shows the expanded map. Writes refuse other targets (code `ref`, listing the valid ones), a link to the row itself (`ref`), a link to no row of the table (`broken_link`) and a missing link a level needs (`required`). Pass the row (`row`: path, link or name; a name rows in different folders share is refused, listing their paths) and/or its values (`values`, e.g. `{"kind": "workstream"}` for a new row). Returns `{rows: [{name, link, path, <level column>}], total, required, empty, reason}` (no rows, and the reason, for a level the map lacks); write a row’s `link` as the value.
49
+
50
+ Examples: [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/).
51
+
52
+ | Parameter | Type | Required | Default | Description |
53
+ | --------- | ---------- | -------- | ------- | ------------------------------------------ |
54
+ | `table` | string | yes | | |
55
+ | `column` | string | yes | | A link column (or list of links) with ref. |
56
+ | `row` | string \\ | null | | `null` |
57
+ | `values` | object \\ | null | | `null` |
58
+ | `limit` | integer \\ | null | | `null` |
59
+
60
+ ## `read_note`
61
+
62
+ **Read Note** · read-only
63
+
64
+ Read a note or another file of the vault: `{path, content, front_matter, tags, modified_at, created_at, size}`. `content` is the whole text, front matter included; `tags` are without `#`, from the text and the front matter; the times are in the database’s time zone. A missing file is an error. `path`: vault-relative, forward slashes.
65
+
66
+ Examples: [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/), [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/), [Read and search notes](https://datanotes.dev/guides/search/text/).
67
+
68
+ | Parameter | Type | Required | Default | Description |
69
+ | --------- | ------ | -------- | ------- | ------------------------------------------------------------------ |
70
+ | `path` | string | yes | | The file’s vault path, with its extension (“Films/Metropolis.md”). |
71
+
72
+ ## `list_folder`
73
+
74
+ **List Folder** · read-only
75
+
76
+ The direct children of a vault folder: `{folder, folders, files}`, each a vault path, sorted; dot-files and dot-folders are left out. `folder` “” is the vault root. A missing folder is an error.
77
+
78
+ Examples: [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/), [Tables](https://datanotes.dev/guides/database-objects/tables/), [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/), [Read and search notes](https://datanotes.dev/guides/search/text/).
79
+
80
+ | Parameter | Type | Required | Default | Description |
81
+ | --------- | ------ | -------- | ------- | -------------------------------------------- |
82
+ | `folder` | string | | `""` | Vault-relative folder; “” is the vault root. |
83
+
84
+ ## `search_notes`
85
+
86
+ **Search Notes** · read-only
87
+
88
+ Plain-text search: every word of `query` must occur, case- and accent-insensitive, in the note’s path or text; there are no operators. Returns `{query, results: [{path, score, matches: [{start, end, context}]}], total}`, best first: at most 200 notes (`total` counts them all) and 20 matches per note. `context_length`: characters of context on each side (default 100, max 1000).
89
+
90
+ Examples: [Read and search notes](https://datanotes.dev/guides/search/text/).
91
+
92
+ | Parameter | Type | Required | Default | Description |
93
+ | ---------------- | ------- | -------- | ------- | ------------------------------------------------------------- |
94
+ | `query` | string | yes | | |
95
+ | `context_length` | integer | | `100` | Characters of context on each side of a match (at most 1000). |
96
+
97
+ ## `semantic_search`
98
+
99
+ **Semantic Search** · read-only
100
+
101
+ Find notes by meaning, not exact words: `{query, results: [{path, score, heading, snippet, table?}]}`, one result per note (its best passage), best first. Use it for vague questions (“the dinner where we talked about moving”, “what did I decide about the car”) and to find the rows to read or update; then read_note / select_rows for the details. Filters: `tables` (qualified or short names), `folder`, `min_score` (cosine 0–1; \~0.5+ is usually relevant). `limit`: default 10, max 100. Fails with a clear message when semantic search is not enabled in the engine settings.
102
+
103
+ Examples: [Find notes by meaning](https://datanotes.dev/guides/search/semantic/).
104
+
105
+ | Parameter | Type | Required | Default | Description |
106
+ | ----------- | ------------ | -------- | ------- | ----------- |
107
+ | `query` | string | yes | | |
108
+ | `limit` | integer | | `10` | |
109
+ | `tables` | string\[] \\ | null | | `null` |
110
+ | `folder` | string \\ | null | | `null` |
111
+ | `min_score` | number \\ | null | | `null` |
112
+
113
+ ## `graph_neighbors`
114
+
115
+ **Graph Neighbors** · read-only
116
+
117
+ Direct neighbours of notes: what they link to (`out`) and what links to them (`in`, backlinks), with counts per edge label. `direction`: out, in or both (default).
118
+
119
+ `from_nodes` selects the notes: `{"paths": [...]}` and/or `{"table": ..., "where": {...}}`. Edges are labelled with their link column (`people`, `event`, …) or `link` for other links.
120
+
121
+ Examples: [Walk the link graph](https://datanotes.dev/guides/search/link-graph/).
122
+
123
+ | Parameter | Type | Required | Default | Description |
124
+ | ------------ | ------------ | --------- | ----------- | ----------- |
125
+ | `from_nodes` | object | yes | | |
126
+ | `direction` | `"out"` \\ | `"in"` \\ | `"both"` \\ | null |
127
+ | `edges` | string\[] \\ | null | | `null` |
128
+
129
+ ## `graph_traverse`
130
+
131
+ **Graph Traverse** · read-only
132
+
133
+ Breadth-first walk over links from `from_nodes` (`{"paths": [...]}` and/or `{"table", "where"}`).
134
+
135
+ * `direction`: out (default, follow links), in (follow backlinks) or both.
136
+ * `edges`: edge labels to follow (link columns such as `people`, `event`, or `link`).
137
+ * `tables`: return only notes of these tables; `through`: only walk on through these tables.
138
+ * `min_depth` (default 1) / `max_depth` (default 2, max 10), `limit` (default 500).
139
+
140
+ Each node comes with `depth` and `via` (one shortest route). Example — moods tied to events with Alice: from `{"table": "person", "where": {"name": "Alice"}}`, direction `in`, edges `["people", "event"]`, tables `["mood"]`, max_depth 2. Feed the paths to `select_rows` with `where: {"path": {"in": [...]}}` to aggregate them.
141
+
142
+ Examples: [Walk the link graph](https://datanotes.dev/guides/search/link-graph/).
143
+
144
+ | Parameter | Type | Required | Default | Description |
145
+ | ------------ | ------------ | --------- | ----------- | ----------- |
146
+ | `from_nodes` | object | yes | | |
147
+ | `direction` | `"out"` \\ | `"in"` \\ | `"both"` \\ | null |
148
+ | `edges` | string\[] \\ | null | | `null` |
149
+ | `tables` | string\[] \\ | null | | `null` |
150
+ | `through` | string\[] \\ | null | | `null` |
151
+ | `min_depth` | integer \\ | null | | `null` |
152
+ | `max_depth` | integer \\ | null | | `null` |
153
+ | `limit` | integer \\ | null | | `null` |
154
+
155
+ ## `graph_path`
156
+
157
+ **Graph Path** · read-only
158
+
159
+ Shortest chain of links between two sets of notes (each `{"paths": [...]}` and/or `{"table", "where"}`): `found`, `length` and `path`: the steps (`from`, `label`, `direction`, `to`). `direction` both by default; `max_depth` default 6 (max 10).
160
+
161
+ Examples: [Walk the link graph](https://datanotes.dev/guides/search/link-graph/).
162
+
163
+ | Parameter | Type | Required | Default | Description |
164
+ | ------------ | ------------ | --------- | ----------- | ----------- |
165
+ | `from_nodes` | object | yes | | |
166
+ | `to_nodes` | object | yes | | |
167
+ | `direction` | `"out"` \\ | `"in"` \\ | `"both"` \\ | null |
168
+ | `edges` | string\[] \\ | null | | `null` |
169
+ | `max_depth` | integer \\ | null | | `null` |
@@ -0,0 +1,185 @@
1
+ # Row operations (DML)
2
+
3
+ > Operations that write rows: insert, update, merge, delete, move, adopt and batch.
4
+
5
+ Operations that write rows: insert, update, merge, delete, move, adopt and batch. The [overview](https://datanotes.dev/reference/operations/) lists every operation by kind. The MCP server, `datanotes mcp`, offers each operation as an MCP tool of the same name, and `engineTools()` of `datanotes/mcp` gives the same definitions to [your own MCP server](https://datanotes.dev/develop/build-on-datanotes/#build-your-own-mcp-server). `DatanotesClient.call(name, args)` runs one from code. Over HTTP each one is `POST /datanotes/operations/<name>/`, with its arguments as the JSON body: the [HTTP API reference](https://datanotes.dev/api/) lists them.
6
+
7
+ Every write is validated. Writes to rows and to the schema are journaled and undone with `undo_migration`; `configure_database`, the webhook operations, `vacuum_table` and `sync_semantic_index` are not journaled.
8
+
9
+ ## `insert_row`
10
+
11
+ **Insert Row** · write
12
+
13
+ Insert a row (new note). Values are validated against the columns; the note path comes from the table’s `path`/`filename` patterns (e.g. an event logged today about last night lands in last night’s day folder when you set `occurred_at` to last night). `body` is the note text. Generated / identity columns are computed (do not pass them); CHECK constraints are enforced. Returns `migration_id` (undo) and the created path in `planned_creates`. `body` links the notes it mentions by name, at their first mention (automatic links; off with `autolink: false` or the database’s `autolink` setting). `links_added` lists the links made; `ambiguous_mentions` lists the mentions left as text with the notes they may name: read those, then link the right one with update_row and `autolink: false`, or leave the text.
14
+
15
+ Examples: [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/), [Tables](https://datanotes.dev/guides/database-objects/tables/), [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Bases](https://datanotes.dev/guides/database-objects/bases/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [Validation](https://datanotes.dev/guides/data-quality/validation/), [CHECK constraints](https://datanotes.dev/guides/data-quality/check-constraints/), [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/), [Automatic links](https://datanotes.dev/guides/read-and-write/automatic-links/), [Batch writes](https://datanotes.dev/guides/read-and-write/batch/), [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/), [Journal and undo](https://datanotes.dev/guides/history/journal-and-undo/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/), [Change data feed](https://datanotes.dev/guides/history/change-data-feed/), [Restore a table or the database](https://datanotes.dev/guides/history/restore/).
16
+
17
+ | Parameter | Type | Required | Default | Description |
18
+ | ---------- | ---------- | -------- | ------- | ----------- |
19
+ | `table` | string | yes | | |
20
+ | `values` | object | yes | | |
21
+ | `body` | string \\ | null | | `null` |
22
+ | `path` | string \\ | null | | `null` |
23
+ | `dry_run` | boolean | | `false` | |
24
+ | `autolink` | boolean \\ | null | | `null` |
25
+
26
+ ## `update_row`
27
+
28
+ **Update Row** · destructive write
29
+
30
+ Update exactly ONE row, addressed by its `id` (the system UUID) or its `path`; refused when the row does not exist (or id and path disagree). Same validation, journal and history as `update_rows`.
31
+
32
+ * `set` / `unset`: columns to set or remove.
33
+ * `body`: replace the whole note body; or edit it keeping the rest: `body_sections` `{"History": "…"}` replaces the text under that heading (any level, up to the next heading of the same level; added as `## History` when missing), `body_prepend` / `body_append` add text before / after.
34
+ * `expect`: compare-and-set — `{"status": "open"}` writes only if the row still has those values (a person may have changed it since you read it); otherwise refused, nothing written.
35
+ * `autolink`: the text written links the notes it mentions by name, at their first mention (off with `autolink: false` or the database’s setting). `links_added` lists the links made; `ambiguous_mentions` the mentions left as text with the notes they may name: read those, then link the right one with update_row and `autolink: false`, or leave the text.
36
+
37
+ Examples: [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Bases](https://datanotes.dev/guides/database-objects/bases/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [CHECK constraints](https://datanotes.dev/guides/data-quality/check-constraints/), [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/), [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/), [Automatic links](https://datanotes.dev/guides/read-and-write/automatic-links/), [Batch writes](https://datanotes.dev/guides/read-and-write/batch/), [Journal and undo](https://datanotes.dev/guides/history/journal-and-undo/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/), [Change data feed](https://datanotes.dev/guides/history/change-data-feed/), [Restore a table or the database](https://datanotes.dev/guides/history/restore/).
38
+
39
+ | Parameter | Type | Required | Default | Description |
40
+ | --------------- | ------------ | -------- | ------- | ----------- |
41
+ | `table` | string | yes | | |
42
+ | `id` | string \\ | null | | `null` |
43
+ | `path` | string \\ | null | | `null` |
44
+ | `set` | object \\ | null | | `null` |
45
+ | `unset` | string\[] \\ | null | | `null` |
46
+ | `body` | string \\ | null | | `null` |
47
+ | `body_sections` | object \\ | null | | `null` |
48
+ | `body_prepend` | string \\ | null | | `null` |
49
+ | `expect` | object \\ | null | | `null` |
50
+ | `body_append` | string \\ | null | | `null` |
51
+ | `dry_run` | boolean | | `false` | |
52
+ | `autolink` | boolean \\ | null | | `null` |
53
+
54
+ ## `update_rows`
55
+
56
+ **Update Rows** · destructive write
57
+
58
+ Update every row matching `where` (required: `{}` is every row). `where`: keys AND-ed; values are equality or operators eq, ne, gt, gte, lt, lte, in, contains, icontains (case/accent-insensitive, also inside lists — use it for names and aliases), exists, within (a hierarchy link: that row and everything below); combine with `or` / `and` / `not` (nestable); `path` is a pseudo-column. A dotted key follows a link column: `{"project.area": "[[Work]]"}` matches rows whose `project` links a row with that `area`. `set` sets, `unset` removes; all rows are validated first. `expect_count`: refuse unless exactly that many match. One row, or its text: update_row.
59
+
60
+ Examples: [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/).
61
+
62
+ | Parameter | Type | Required | Default | Description |
63
+ | -------------- | ------------ | -------- | ------- | ------------------------------------------------- |
64
+ | `table` | string | yes | | |
65
+ | `where` | object | yes | | The rows to change; {} is every row of the table. |
66
+ | `set` | object \\ | null | | `null` |
67
+ | `unset` | string\[] \\ | null | | `null` |
68
+ | `dry_run` | boolean | | `false` | |
69
+ | `expect_count` | integer \\ | null | | `null` |
70
+
71
+ ## `merge_rows`
72
+
73
+ **Merge Rows** · destructive write
74
+
75
+ MERGE (upsert) `rows` into `table` by the key columns `on` (e.g. `["occurred_at"]` or `["id"]`): a row matching an existing one updates it (`when_matched`: “update” default or “ignore”), the others are inserted (`when_not_matched`: “insert” default or “ignore”). Date-times are compared after completion with the database time zone. A source key matching several rows, or repeated, is a conflict. One journaled, undoable operation.
76
+
77
+ Examples: [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/).
78
+
79
+ | Parameter | Type | Required | Default | Description |
80
+ | ------------------ | ------------- | ------------- | ------- | ----------- |
81
+ | `table` | string | yes | | |
82
+ | `on` | string\[] | yes | | |
83
+ | `rows` | object\[] | yes | | |
84
+ | `when_matched` | `"update"` \\ | `"ignore"` \\ | null | |
85
+ | `when_not_matched` | `"insert"` \\ | `"ignore"` \\ | null | |
86
+ | `dry_run` | boolean | | `false` | |
87
+
88
+ ## `delete_rows`
89
+
90
+ **Delete Rows** · destructive write
91
+
92
+ Delete rows matching `where`. `mode`: “archive” (default, move to the table’s archive folder) or “delete” (trash; content journaled for undo). `on_referenced`: “restrict” (default, refuse rows other notes link to), “set_null” (clear front matter links to them) or “ignore” (the links stay, to no row: an archived row is gone as a trashed one, so check_table reports them as `broken_link` and new links to it are refused). `where` is required: `{}` deletes every row.
93
+
94
+ Examples: [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/).
95
+
96
+ | Parameter | Type | Required | Default | Description |
97
+ | --------------- | --------------- | --------------- | ------------- | ------------------------------------------------- |
98
+ | `table` | string | yes | | |
99
+ | `where` | object | yes | | The rows to change; {} is every row of the table. |
100
+ | `mode` | `"archive"` \\ | `"delete"` \\ | null | |
101
+ | `on_referenced` | `"restrict"` \\ | `"set_null"` \\ | `"ignore"` \\ | null |
102
+ | `dry_run` | boolean | | `false` | |
103
+
104
+ ## `move_rows`
105
+
106
+ **Move Rows** · destructive write
107
+
108
+ Move rows matching `where` (required: `{}` is every row) to another table (e.g. split a domain out of `log` into its own table): sets each row’s `table` to the destination, applies `rename` (`{"metric_distance_km": "distance_km"}`), `set` and `drop`, adds the destination’s missing dense fields, and validates every row against the destination first. Keys unknown to the destination are reported, never dropped silently — rename or drop them explicitly. `relocate: true` also moves the files to the destination table’s folder (named by its filename pattern); by default rows stay where they are, as rows already in folders of their own usually do (adopt_rows, for notes that are no rows yet, moves them by default). Refused while rows staying behind link to a moved row through a column whose `ref` is the source table (the conflicts name them): change those links first. Undo with `undo_migration`.
109
+
110
+ Examples: [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/).
111
+
112
+ | Parameter | Type | Required | Default | Description |
113
+ | ---------- | ------------ | -------- | ------- | ------------------------------------------------- |
114
+ | `table` | string | yes | | |
115
+ | `to_table` | string | yes | | |
116
+ | `where` | object | yes | | The rows to change; {} is every row of the table. |
117
+ | `rename` | object \\ | null | | `null` |
118
+ | `set` | object \\ | null | | `null` |
119
+ | `drop` | string\[] \\ | null | | `null` |
120
+ | `relocate` | boolean | | `false` | |
121
+ | `dry_run` | boolean | | `false` | |
122
+
123
+ ## `adopt_rows`
124
+
125
+ **Adopt Rows** · destructive write
126
+
127
+ Turn existing notes (not rows of any table yet) into rows of `table`, keeping their body and links: `rename` keys (`{"data": "occurred_at"}`), `set` for all, `per_row` values by note path (`{"Home/x.md": {"zone": "[[Kitchen]]"}}`), `drop` keys the table does not have. Every note gets `table` and a system `id`; with `relocate` (default true, unlike move_rows: notes become rows where the table keeps its rows) it moves to the table’s folder, named by its filename pattern (links to it are rewritten). All notes are validated first (as rows of `table`, so notes of the same call may link to one another): unknown keys and bad values are listed and nothing is written. Run with `dry_run` first; undo with `undo_migration`. Many notes: adopt them in calls of about 1,000 `paths` each, so a stop or a crash interrupts less (each call is one journal entry).
128
+
129
+ Examples: [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/).
130
+
131
+ | Parameter | Type | Required | Default | Description |
132
+ | ---------- | ------------ | -------- | ------- | ----------- |
133
+ | `table` | string | yes | | |
134
+ | `paths` | string\[] | yes | | |
135
+ | `rename` | object \\ | null | | `null` |
136
+ | `set` | object \\ | null | | `null` |
137
+ | `per_row` | object \\ | null | | `null` |
138
+ | `drop` | string\[] \\ | null | | `null` |
139
+ | `relocate` | boolean | | `true` | |
140
+ | `dry_run` | boolean | | `false` | |
141
+
142
+ ## `batch`
143
+
144
+ **Batch** · destructive write
145
+
146
+ Several writes that succeed or fail together. `operations`: `[{"op": ..., ...arguments}]` where `op` is a row operation (`insert_row`, `update_row`, `update_rows`, `delete_rows`, `merge_rows`, `move_rows`, `adopt_rows`, `recompute_columns`, `align_relations`, `restore_table`) or a DDL op (`create_table`, `add_column`, `alter_column`, …), with the same arguments as the operation (an unknown one refuses the batch) (e.g. `values` for insert_row, `set` for update_row / update_rows). They run in order, each seeing the previous ones; if one is refused, the ones already applied are undone (`rolled_back`). Returns `steps` (per operation, each with its result, where `ambiguous_mentions` is as in insert_row) and `migration_id`: undo_migration on it reverts the whole batch. Use it when a change spans several rows (create an event and update the people in it). `dry_run` checks each operation against the current data only.
147
+
148
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
149
+
150
+ Examples: [Views](https://datanotes.dev/guides/database-objects/views/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [CHECK constraints](https://datanotes.dev/guides/data-quality/check-constraints/), [Batch writes](https://datanotes.dev/guides/read-and-write/batch/), [Restore a table or the database](https://datanotes.dev/guides/history/restore/).
151
+
152
+ | Parameter | Type | Required | Default | Description |
153
+ | ------------ | --------- | -------- | ------- | ----------- |
154
+ | `operations` | object\[] | yes | | |
155
+ | `summary` | string \\ | null | | `null` |
156
+ | `dry_run` | boolean | | `false` | |
157
+
158
+ ## `align_relations`
159
+
160
+ **Align Relations** · destructive write
161
+
162
+ Add the reciprocal links missing on a table’s `inverse` link columns (e.g. Alice lists Carol in `friends` but Carol does not list Alice). Run it after declaring `inverse` on existing data; check_table reports such rows (code `inverse`). Single-value links already pointing elsewhere are conflicts (nothing written). The links it adds are checked like other writes (CHECKs that follow links, `ref_where` / `ref_by`). Writes through the tools already keep both sides in step.
163
+
164
+ Examples: [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/).
165
+
166
+ | Parameter | Type | Required | Default | Description |
167
+ | --------- | ------------ | -------- | ------- | ----------- |
168
+ | `table` | string | yes | | |
169
+ | `paths` | string\[] \\ | null | | `null` |
170
+ | `dry_run` | boolean | | `false` | |
171
+
172
+ ## `recompute_columns`
173
+
174
+ **Recompute Columns** · destructive write
175
+
176
+ Bring generated and identity columns up to date (all rows, or only `paths`), e.g. after rows were edited by hand (an editor, git, sync) or a generated expression changed with `alter_column`. Also gives rows without an `id` a new one, and a duplicated note (same `id` as an older row) a new id. `new_ids=true` regenerates every id in scope (new ones on every call): only on the user’s explicit request. `check_table` reports stale values with code `generated`. No-op when nothing is stale; otherwise journaled (undo_migration) and a RECOMPUTE version in the table’s history.
177
+
178
+ Examples: [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/).
179
+
180
+ | Parameter | Type | Required | Default | Description |
181
+ | --------- | ------------ | -------- | ------- | ----------- |
182
+ | `table` | string | yes | | |
183
+ | `paths` | string\[] \\ | null | | `null` |
184
+ | `new_ids` | boolean | | `false` | |
185
+ | `dry_run` | boolean | | `false` | |