SERVER / DATABASE / WRITE
Insert
Insert creates one record in a declared table and returns the created value. Database creates a ULID id when the value does not provide one.
1 / CREATE
Validate input before the write
The handler already has the request context as req, keeps the table name static, and asks Database to require non-empty title and content values. The same insert query works with postgres, d1, or dowe; this example declares dowe.
handler createBlog
database db provider:"dowe" host:env.DOWE_HOST port:env.DOWE_PORT account:env.DOWE_USER secret:env.DOWE_PASSWORD name:"content"
query created conn:db.insert table:"blogs" value:{ title:req.body.title content:req.body.content createdAt:now } required:["title" "content"]
return status:201 json:{ ok:true data:created }Contract | What Dowe enforces |
|---|---|
No dataThere are no records to display | |