Files
marqdo/ext/data/view.mq.md
T
cflmy 9331af78e2 release(2.8.0): 合入 CHANGELOG/README/发版说明/skills prove 任务;CI 链接指向 doc/releases
- CHANGELOG.md:v2.8.0 条目(中英双语);
- README.md:版本行 2.7.1→2.8.0 + 愿景第 6 条(知识可证明);
- doc/releases/v2.8.0.md:双语发版说明(亮点/用法/已知限制);
- skills/marqdo-dev/index.mq.md:新增 prove 任务(路径/目录模式/
  require_lean/json;参数用 + 行声明升参,check 与 narrative-ratio 通过);
- 设计文档 §12.5 标记已合入;发版链接统一指向 doc/releases/v2.8.0.md。
2026-11-18 10:29:26 +08:00

41 lines
3.3 KiB
Markdown
Executable File

---
markup: occlusion
title: Request-time database View resources
---
Use this single-file resource handbook when a recursively composed page needs current database rows on each request. Construction is pure: it records a query without connecting, selecting or rendering HTML. Place the result in component.resource and retain view: main for startup layout assembly. The application supplies its actual database resource when serving.
Do not combine view: main with automatic data_source metadata. Ordinary Documents keep that metadata path; explicit View pages use this query Resource instead. A missing database, invalid condition or backend failure remains a request error, never a fabricated empty list. See [the request-resource design](../../doc/design/web-view-resources.md).
## query
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| source | text | required | Existing table on the serving application's database |
| where | any | None | Native condition map or list; route placeholders resolve from actual request params |
| order | text | "" | Native database ordering, such as -created_at |
| limit | number | 50 | Integer from 1 through 1000 |
| detail | bool | False | False renders cards; True renders the first matching full article |
| link_prefix | text | "/post/" | Site-relative prefix applied to row slugs, or empty for no prefix |
| tenant_scope | bool | False | Require an attached tenant policy and current tenant filter |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Pure data_query Resource; no query has executed yet |
Use `source`, `where`=None, `order`="", `limit`=50, `detail`=False, `link_prefix`="/post/" and `tenant_scope`=False. The native renderer validates the contract before listening, then selects current records for each request. Card titles and summaries are escaped; article content uses the existing Markdown renderer. Detail mode prefers the complete body/content even when a summary exists.
Rows follow the current Document convention: title, slug or href, summary, body or content, optional created_at/meta and tag. This fixed projection preserves the native card/article surface without restoring a private binding-table DSL. Layout remains in parent components; this resource only supplies one dynamic content region. For a different domain projection, keep a separate documented resource rather than passing arbitrary page configuration.
Conditions are copied before replacing route placeholders, so one request cannot mutate another's retained definition. Path parameters take precedence over query keys. A requested tenant scope requires actual tenant configuration and context; direct selectors do not prove user membership. Link visibility and data filtering do not replace authentication or server authorization.
This constructor needs no effects. Serving needs the actual web/database plugin and the launcher grants. Rendering the Resource offline without request context reports that requirement explicitly. Reading this file does not authorize a query, write or network listener.
`resource` =
| _type | source | where | order | limit | detail | link_prefix | tenant_scope |
|---|---|---|---|---|---|---|---|
| data_query | `source` | `where` | `order` | `limit` | `detail` | `link_prefix` | `tenant_scope` |
Once its intended request behavior is explicit, return *resource* for placement in a View resource node.