Documentation
¶
Overview ¶
Package dataview registers the built-in `dataview` type — saved views over a set of objects, in two levels: a dataview object hosts many DATAVIEWS, each with its own VIEWS.
A dataview object is an object of this type (its one type), created for the object it serves: `host` names that object — any object, a type or a collection definition included (a view "on a type" is a dataview object whose host is the type). The type owns two records datasets under one part: `dataviews` (one record per dataview — name, icon, pos) and `views` (one record per view — the dataview it belongs to, name, icon, pos, layout, a query, column settings). The added level is what lets one host carry several independent tables, each with its own set of views.
A view is name + icon + layout + a query + column settings. The query and the column settings stay OPAQUE to the server: clients own the filter/sort/groupBy vocabulary and decide what a rule naming a deleted property means. Validating property references here would turn a deleted property into a write failure instead of a rule the client marks invalid. The same holds one level up: a view's `dataview` names a record in `dataviews` and is not validated against it — a dataview deleted under its views must not make them unwritable. There is no cascade; orphan views are the client's to delete or re-parent.
Why built-in: views are shared client vocabulary, not app data — any-ui, mobile and desktop must land on the SAME records or a view saved in one client is invisible in the next. A client-minted user type passes each peer's local check-then-create and merges, leaving a space with several parallel "Views" types. A registered type exists in every space by construction. Hidden: a capability an object opts into, not a class a user picks.
Iteration 1 is the SHARED tier: one set of dataviews and views, visible to everyone with space access. Account-private and device-private tiers need scoped DATASETS — the SDK scopes fields, and its account mirror covers `objects` rows only.
Writes go through POST /v1/spaces/:id/modify, reads through /query[/subscribe] with dataset=dataviews or views. No bespoke endpoints — the record shapes carry no server semantics worth one — and no `dataview` module: both datasets run on the generic `records` handler.
Index ¶
Constants ¶
const ( // TypeId is reserved — content-addressable user type ids never // produce it, and the server's xKey guard rejects user types // claiming it. TypeId = "dataview" Name = "Data view" Description = "Saved views over a set of objects: dataviews for a host, each with its own views (layout + query + column settings)" // PropHost is the object the dataview object serves — the object, // type or collection its views are over. PropHost = "host" // PartViews is the type's single part; it owns both datasets. PartViews = "views" // DatasetDataviews holds one record per dataview on the host. DatasetDataviews = "dataviews" // DatasetViews holds one record per view; `dataview` names the // dataviews record it belongs to. DatasetViews = "views" // DataVersions are stamped on every change and gated by peers. DataVersionDataviews = "dataviews-v1" DataVersionViews = "views-v1" )
const ( FieldName = "name" FieldIcon = "icon" FieldPos = "pos" FieldCreator = "creator" FieldCreatedAt = "createdAt" FieldModifiedAt = "modifiedAt" )
Record field names shared by both datasets.
const ( // FieldDataview is the id of the `dataviews` record the view belongs // to. Required; free to rewrite (a view moves between dataviews); // never validated against the collection. FieldDataview = "dataview" FieldLayout = "layout" // FieldQuery is the /query body shape verbatim — filter / sort / // groupBy — plus a `type` discriminator, `"plain"` today. The // discriminator exists so an aggregation-backed view lands later // without a migration. FieldQuery = "query" // FieldLayoutSettings is the synced column state (visible / order, // and widths as a shared baseline). FieldLayoutSettings = "layoutSettings" // FieldLocalSettings is this device's override of layoutSettings, // same vocabulary. Column-drag autosave lands here so the churn // never syncs; the client merges local over synced. Scope is // per top-level field, so the override cannot live inside // layoutSettings. FieldLocalSettings = "localSettings" )
View record fields (dataset `views`).
Variables ¶
This section is empty.
Functions ¶
func NewType ¶
NewType returns the handler.Type to add to config.Config.Types (see internal/server/sdk.go).
Handlers are nil: the declarations below are complete enough for the SDK's generic schema handler — required-on-create, mutability, apply-time stamps, user-supplied ids and the delete gate all come from them, with no bespoke code to keep in step.
Types ¶
This section is empty.