Skip to main content
Version: 3.x

View

Preview Feature
View support is in preview and may be subject to breaking changes in future releases.

The view construct is used to define a SQL view. Defining a view is pretty much the same as defining a model, with the exception that views cannot have index or id fields (designated with @id, @@id, or @@index attributes).

Defining views​

A typical view looks like this:

view UserInfo {
id Int
email String @unique
postCount Int
}

Migration support​

The migration engine doesn't support views, so it's your responsibility to either manually create them in the database, or use the --create-only to create an empty migration record and manually add view creation DDL in it. See Database Migration for more details.

Comments
Feel free to ask questions, give feedback, or report issues.

Don't Spam


You can edit/delete your comments by going directly to the discussion, clicking on the 'comments' link below