Skip to content

Query rows: `{table, total, rows: [{path, ...}]}`. `table` may be a view,

POST
/datanotes/operations/select_rows/
curl --request POST \
--url https://example.com/datanotes/operations/select_rows/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "table": "example", "columns": null, "where": null, "order_by": null, "limit": null, "offset": null, "expand": null, "join": null, "group_by": null, "aggregates": null, "include_body": false, "version": null, "timestamp": null, "this_note": null }'

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.

  • 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.
  • columns, order_by (-col descending), limit (default 100, max 1000), offset, expand (inline linked rows’ frontmatter), include_body (the note body as body).
  • join: {"table", "on": {"date(occurred_at)+1": "date(timestamp)"}, "as", "type": "inner"|"left", "columns", "where"} — matches attached under as.
  • 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).
  • 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).
  • 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.
X-Datanotes-View-As
string

Owner only, on reads only (an operation that only reads, tokens/me/, extensions/, the change stream): the request runs with this named token’s permissions and read scope, and the token’s last_seen does not change. A named token sending it gets 403; a request that is not a read gets 400.

Media typeapplication/json
object
table
required
string
columns
Any of:
Array<string>
where
Any of:
object
key
additional properties
any
order_by
Any of:
string
limit
Any of:
integer
offset
Any of:
integer
expand
Any of:
Array<string>
join
Any of:
object
key
additional properties
any
group_by
Any of:
string
aggregates
Any of:
object
key
additional properties
string
include_body
boolean
version
Any of:
integer
timestamp
Any of:
string
this_note
Any of:
string

Done.

Media typeapplication/json
object
table
required

The table, view or base selected, as given.

string
total
required

Matching rows before limit/offset.

integer
rows
required

The rows returned.

Array<object>

A row: path plus the selected columns (missing values are null); body with include_body; the group keys and aggregates with group_by.

object
key
additional properties
any
version

Log version read (time travel only; of the left table with a join, absent for a union or a base).

integer
timestamp

Commit time of that version (time travel only); for a union or a base, the time asked for.

string
versions

Time travel over several tables (a join, a union, a base): the version read of each, by full name.

object
key
additional properties
integer
view

The view whose query ran.

string
key
additional properties
any

Example generated

{
"table": "example",
"total": 1,
"rows": [
{}
],
"version": 1,
"timestamp": "example",
"versions": {
"additionalProperty": 1
},
"view": "example"
}

Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

Missing or wrong bearer token.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

A named token whose read patterns do not cover the table, view or note the request names (such as token cook may not read personal.health.weight). Sets it did not name (listings, bases, search, the graph, the change feed) are filtered instead.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

Unknown table, view, migration, note or folder.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

Ambiguous table name: it matches several tables (paths or tables lists them).

Media typeapplication/json
object
error
required
string
paths

The tables’ folders the name matches.

Array<string>
tables

The qualified tables the name matches.

Array<string>

Example generated

{
"error": "example",
"paths": [
"example"
],
"tables": [
"example"
]
}

Unexpected error.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}