title: Step 7 — Database & CRUD active_step: 7 fetch.notes = "local:notes?sort=created_at:desc"

Step 7 — Database & CRUD

Full create, read, update, delete — from HTML forms, no backend code.

How data fetching works

Declare a fetch.* directive in the <what> block. The local: prefix queries your configured database. The result is available as a template variable.

<what>
fetch.notes = "local:notes?sort=created_at:desc&limit=20"
</what>

<loop data="#notes#" as="note">
  <div>#note.title#</div>
</loop>

Create a note

Use action="/w-action/notes" with method="post" to insert a new record. The form fields become the record's columns.

#flash.success#
#flash.error#
#errors.title#

Your notes

Records are fetched via fetch.notes = "local:notes" in the <what> block at the top of this page.

No notes yet. Create one above.
#note.title#
#note.body#

CRUD reference

Action Form action Method
Create record /w-action/notes POST
Update record /w-action/notes/#id# POST
Delete record /w-action/notes/#id#/delete POST

Query options

<!-- Sort, filter, search, paginate -->
fetch.notes = "local:notes?sort=created_at:desc&limit=10&offset=0"
fetch.active = "local:items?filter=status:active"
fetch.results = "local:posts?search=hello"
What you learned