Database view
A database view is a resource that stores a parameterised SQL query and executes it against a source SQLite database resource.
Filtering can be done by row and/or column.
It supports filtering data by the authenticated account, and can be used to expose a controlled subset of data while leaving the source database hidden or otherwise protected.
For practical creation and execution examples, see Use database view.
Resource model
A database view is created with the volt:database and volt:sqlite-view resource kinds.
The view stores its definition in resource attributes, including:
- Source database ID (
volt:sqlite-view-source) - SQL template (
volt:sqlite-view-sql) - Parameter metadata (
volt:sqlite-view-param-{name}andvolt:sqlite-view-count) - Sub-select flag (
volt:sqlite-view-sub-select)
Views are created and updated through resource metadata (for example via SaveResource), not by creating a physical SQLite VIEW object.
Policy model
Policy is enforced on the view itself, not the source database. This provides a level of isolation between the view and the source database. The view is a logical construct that can be used to expose a controlled subset of data while leaving the source database hidden or otherwise protected.
Database views support independent access control using normal database permissions:
volt:database-readvolt:database-write
Sub-select mode
Views can optionally allow sub-select execution (volt:sqlite-view-sub-select), where callers provide an outer query that wraps the base template.
Sub-select mode is powerful but can broaden what a caller can query. Enable it only when the resulting access pattern has been reviewed and policy is appropriately constrained.
Database vs. view
- A database (
volt:sqlite-database) owns a physical SQLite file. - A database view (
volt:sqlite-view) stores SQL metadata and executes against a source database. - A table is part of SQLite schema inside a database, not a Volt resource.