Files
verse-quote-app/server/db/schema.ts
T
exe.dev user 0a18c774a5
CI / build (push) Successful in 4m26s
Build Verse: a poem-quote app on the agent-native chat template
Adds a Postgres-backed quotes domain (poems/quotes/favorites) exposed as
five agent-native actions (list-quotes, get-random-quote, create-quote,
toggle-favorite, list-favorites) callable from both chat and the React UI
via useActionQuery/useActionMutation. Moves the primary UI from chat to a
mobile-first Quotes/Favorites experience (chat moves to /chat), adds
manual OpenTelemetry instrumentation exporting traces/metrics/logs over
OTLP, and wires a local Docker Postgres for shared state.
2026-07-25 17:42:04 +00:00

36 lines
1.4 KiB
TypeScript

import { table, text, integer } from "@agent-native/core/db/schema";
// A poem a quote is drawn from. Kept minimal — this app curates excerpts,
// not full poem texts.
export const poems = table("poems", {
id: integer("id").primaryKey(),
author: text("author").notNull(),
title: text("title").notNull(),
source: text("source"),
year: integer("year"),
created_at: text("created_at").$defaultFn(() => new Date().toISOString()),
});
// tags_json is a JSON-encoded string array (e.g. '["hope","nature"]").
// Dialect-agnostic schema helpers have no array type, so tags are
// JSON-encoded text — the same convention other first-party templates use.
export const quotes = table("quotes", {
id: integer("id").primaryKey(),
poem_id: integer("poem_id").notNull(),
text: text("text").notNull(),
tags_json: text("tags_json").notNull().default("[]"),
is_user_submitted: integer("is_user_submitted", { mode: "boolean" })
.notNull()
.default(false),
created_at: text("created_at").$defaultFn(() => new Date().toISOString()),
});
// visitor_id is a client-generated anonymous id (localStorage), not a real
// user account — this app has no login requirement.
export const favorites = table("favorites", {
id: integer("id").primaryKey(),
quote_id: integer("quote_id").notNull(),
visitor_id: text("visitor_id").notNull(),
created_at: text("created_at").$defaultFn(() => new Date().toISOString()),
});