With the rest of KScript
Models work with the rest of KScript without any glue:
- Routes. A controller parameter typed as a model, such as
fn show(post: Post), is the record whose key is in the path, or a 404. See Controllers. - Components. An input with the default
@inject(), such asconstruct({ post: Post = @inject() }), takes the record the route holds, so a page may write<post-card />. See components. - Policies.
policy for Post { fn update(user: User, post: Post) => ... }says who may create, read, update and delete a model's records. Ask it with@can(update, $post),@authorize(update, $post),can: updateon a route, or@inject(can: read). See policies. - OpenAPI. A model in a route's input or answer becomes a schema. The key and timestamps are read-only, a relation appears only when it was loaded with
->with(), and->paginate()answers with a page of records. - Sign-in.
http.auth.userskeeps KScript.Auth's users in a model, so@user()is a record.