stevensDemopopulateDemo.ts4 matches
374];
375376// Insert memories into the database
377async function insertDemoMemories() {
378try {
415await insertDemoMemories();
416417console.log("Demo database successfully populated!");
418return "Demo database successfully populated!";
419} catch (error) {
420console.error("Error populating demo database:", error);
421throw error;
422}
stevensDemomemoryUtils.ts1 match
23/**
4* Retrieves all memories from the database
5* @param includeDate Whether to include date-specific memories or not
6* @param startDate Optional start date to filter memories from (ISO format)
stevensDemoindex.ts1 match
12getAllMemories,
13updateMemory,
14} from "./database/queries.ts";
15import { type Memory } from "../shared/types.ts";
16import { blob } from "https://esm.town/v/std/blob";
3435/**
36* Store a chat message in the database
37*/
38export async function storeChatMessage(
stevensDemogetWeather.ts1 match
130}
131132console.log(`Weather forecast updated in the database.`);
133return summary;
134}
125}
126127console.log(`Calendar events imported into the database.`);
128return events;
129} catch (error) {
stevensDemogenerateFunFacts.ts2 matches
89/**
10* Retrieves previously generated fun facts from the memories database
11* @returns Array of previous fun facts
12*/
4748/**
49* Inserts a fun fact into the memories database
50* @param date Date for the fun fact in ISO format
51* @param factText The fun fact text
stevensDemo.cursorrules2 matches
208```
209โโโ backend/
210โ โโโ database/
211โ โ โโโ migrations.ts # Schema definitions
212โ โ โโโ queries.ts # DB query functions
270- Handle API calls properly with proper error catching
271272### Database Patterns
273- Run migrations on startup or comment out for performance
274- Change table names when modifying schemas rather than altering
39return {
40success: true,
41message: "Telegram chat database table created successfully.",
42verification: tableCheck.rows,
43};
ValTownForNotionwebhookAPI15 matches
24});
2526app.post("/example/database/pages", async (c) => {
27// blob keys map to endpoints for the cron resets
28const blobKey = await c.req.url.replace("https://", "");
29const askingFor = c.req.headers.get("asking_for") || "default"; // val.town or default
3031// capture the database id to store in the blob
32const targetId = c.req.headers.get("target_id");
3334// get the pages in this database
35const databaseChildren = await notion.databases.query({ database_id: targetId });
36// delete all pages to prevent bad actors from leaving naughty rows behi
37for (const [key, child] of databaseChildren.results.entries()) {
38const page = await notion.pages.update({
39page_id: child.id,
42}
4344// get the database
45const database = await notion.databases.retrieve({ database_id: targetId });
46// convert the statuses string in the status property into JSON
47const statuses = JSON.parse(database?.properties?.Statuses?.formula?.expression);
48// get the first item on the list of statuses, to set the status for new pages
49const status = statuses[0];
50// add back pages; fresh start for the next person to add favicons
51const defaults = ["val.town", "notion.com", "hono.dev"].reverse();
52// create new database pages from default object
53for (const item of defaults) {
54const page = await notion.pages.create({
55parent: {
56type: "database_id",
57database_id: targetId,
58},
59properties: {
88});
8990app.post("/example/database/page", async (c) => {
91const payload = await c.req.json();
92const data = await payload?.data;
100101// store webhook data in blob storage for resets
102// capture the database id to store in the blob
103const databaseId = data?.parent?.database_id;
104const blobObject = {
105id: databaseId,
106date: new Date(),
107content: askingFor,