table
A table: named columns, each holding values of one type, and rows.
At a glance
- Stored as: the value itself, written inline wherever it is used.
- Read in parts: by a range of lines.
- Edited by: JSON Pointer operations.
- Search: by passage, so full-text and similarity search rank a value by its best passage.
Writing
Write the table as JSON in the form it is stored in, an object with "type": "table" (in any spacing):
data: thecolumns, the rowindexand the rows (data), each row a list of cells in column order;dtypes: the type of each column, one ofstring,integer,number,email,url,phonenumber,address,secret,audioandimage;descriptions: optionally, what each column holds.
{"type": "table", "data": {"columns": ["name", "phone"], "index": [0, 1], "data": [["Ann", "+15555550143"], ["Bo", "+14155550100"]]}, "dtypes": {"name": "string", "phone": "phonenumber"}, "descriptions": {"phone": "Mobile number"}}
Each cell is read as a value of its column's type and stored in that type's form, so a phone number
is stored as +15555550143 however it was written. A table with a cell its column's type refuses is
refused, with the column named. Other text and other JSON shapes, such as a list of rows, are refused
with the form above.
Written as
A JSON string whose schema format is table.
Reading
get_content reads a table as text: one line per column description
(phone: Mobile number), a blank line, then the table in Markdown, with a header row, a separator and one
line per row. Without descriptions, line 1 is the header and line 3 the first row. range counts these
lines. A query in grep mode matches them; in bm25 or hybrid it finds rows, each shown as
4: column: value; column: value, where 4 is the row's line, the number range reads. A table has
no paths, so path is refused.
Querying
No entity field holds a table, so an HQL query over entities does not reach tables. Search inside one
with get_content and a query, or run HQL steps over its rows with
its hql: each row is an object of its columns, so qty > 1 | order by name keeps the rows whose
qty is over 1.
Every operator is in the HQL reference.
Editing
edit changes the stored JSON with JSON Pointer ops. A cell is at
/data/data/<row>/<column>, both counted from 0 in the order written:
{"op": "replace", "path": "/data/data/0/1", "value": "+15555550199"}. A column's type is at
/dtypes/<column name> and its description at /descriptions/<column name>. The result is a new table
under a new handle, checked like a new one: an edit that leaves a cell its column's type refuses is
refused.
Operations
Through the dtypes resource: