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

peterqliu

SQLiteTable

Public
Like
SQLiteTable
Home
Code
2
README.md
main.tsx
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
/
README.md
Code
/
README.md
Search
6/24/2024
Viewing readonly version of main branch: v162
View latest version
README.md

SQLiteTable

A thin abstraction over SQLite, to work with tables from vals. All methods async.

Usage

new SQLiteTable("myTable") .create({ id: "unique primary key", title: "text", body: "text", created: "integer", })

API

new SQLiteTable(title:string)

Start an instance of SQLiteTable.

.create(scheme:TableScheme)

Create this table in your VT SQLite storage. scheme is a JSON with column names as keys, and definitions as values (see above for example). Run this only once per table.

.drop()

Drop this table from your VT SQLite storage.

.insertRow(rowData)

Add a new row to your table. rowData is a JSON with column names as keys, and row values as values.

table.insertRow({ id: 1234, title: 'Post title', body: 'Post body', created: 12345678 })

.getRow(conditions?)

Return the first row matching the provided condition. condition is a JSON of column-value equalities that the desired row must match.

table.getRow({ id: 1234, title: 'Post title' })

.getRows(conditions?)

Same, except returns all matching rows.

.countRows(conditions?)

Returns a count of all rows in the table that match the condition.

.deleteRows(conditions?)

Deletes all rows in the table that match the condition.

.updateRow(conditions?, rowData)

Modifies all rows in the table that match the condition. rowData is a JSON of key-value pairs to change; it does not affect any columns not mentioned.

table.updateRow( {id: 1234}, {title: 'New title! The existing body text is not mentioned here so it is unaffected'} )

Migrated from folder: sqlite/SQLiteTable

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.