• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
nbbaier

nbbaier

serialize-email

Public
Like
serialize-email
Home
Code
2
README.md
main.ts
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
Code
/
Search
README.md

SQLite Email Storage Utilities

Simple utilities for storing and retrieving email data in SQLite on Val Town.

Functions

createTable(tableName: string)

Creates a table with the following schema:

  • id - INTEGER PRIMARY KEY
  • timestamp - INTEGER NOT NULL (Unix timestamp)
  • data - TEXT NOT NULL (JSON string)

insertEmail(tableName: string, data: Email)

Inserts an email object into the specified table with the current timestamp.

getLatestEmail(tableName: string): Promise<Email>

Retrieves the most recently inserted email from the specified table, ordered by timestamp.

getAllEmails(tableName: string): Promise<Email[]>

Retrieves all emails from the specified table as an array of Email objects.

Usage

Create val
import { createTable, getAllEmails, getLatestEmail, insertEmail, } from "https://esm.town/v/nbbaier/serialize-email/main.ts"; // Create table await createTable("my_emails"); // Insert email data await insertEmail("my_emails", emailObject); // Get the latest email const latestEmail = await getLatestEmail("my_emails"); // Get all emails const allEmails = await getAllEmails("my_emails");

Requirements

  • Val Town SQLite standard library
  • Email objects must be JSON serializable
Code
README.mdmain.ts
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.