App data
Every app can have its own SQLite database with full-text search and vector search. Learn who can read and write it, how visitors save data safely, and how to share it between your apps.
An app can keep data with Studio Data. Each app has one SQLite database of its own, which stays with the app for as long as the app exists. It supports full-text search (FTS5) and vector search (sqlite-vec). The AI builder creates it and writes into it, and the running app reads it and lets visitors save things through safe, named operations.
The idea in one minute
The builder (you, through the AI builder) creates the tables and writes data, such as a list of books.
The running app reads the data to show it, with
smn.db.queryorsmn.db.all.Visitors can change data only through operations you define, such as
add_book. A visitor can never run arbitrary SQL that changes anything.
Create the database
You do not write SQL for the structure. Describe it to the AI builder:
Add a database table for books with title, author, a short note and when it was added. Fill it with these five books. Add an operation add_book so visitors can add one. Add full-text search over title, author and note.
The builder creates the tables and indexes, loads the rows, defines the operation and updates your app to use them. A destructive change to existing data, such as dropping a table, needs your approval first. See Build an app with AI.
If you write the code yourself, the builder still creates the database: ask it for the tables and operations, then call them from your code.
Read data
Use the helper in your page or in a server function:
// All books, as objects
const books = await smn.db.all('SELECT title, author FROM books ORDER BY title LIMIT 50');
// With a value passed safely as a parameter
const byAuthor = await smn.db.all('SELECT title FROM books WHERE author = ?', ['Ursula K. Le Guin']);
smn.db.query(sql, params)returns{ columns, rows, truncated }.smn.db.all(sql, params)returns the same rows as objects keyed by column name.Reads are read-only: one statement,
SELECTonly, with a time limit and a cap on the number of rows and the size of the answer. If the answer was cut,truncatedis true.smn.db.schema()lists the tables, their columns and the operations.
Always pass values as parameters (?), never by joining them into the SQL text.
Full-text search
With an FTS5 table that the builder created, search by words and rank by relevance:
const hits = await smn.db.all(
'SELECT rowid, title FROM books_fts WHERE books_fts MATCH ? ORDER BY bm25(books_fts) LIMIT 20',
[searchText]
);
Vector search
SeeMyNotes does not create embeddings for you. If your app wants search by meaning, it brings its own vectors: for example from an AI provider through a connection, or computed beforehand. The vectors are stored in a vector table, and a query compares a list of numbers with them:
const near = await smn.db.all(
'SELECT rowid, distance FROM chunks_vec WHERE embedding MATCH ? AND k = 5 ORDER BY distance',
[queryVector] // a list of numbers with the same length as the stored vectors
);
Let visitors save data: operations
Visitors change data by calling an operation: a named, ready-made statement with named parameters. You ask the builder to define it ("add an operation add_book that takes title and author"). The page calls it by name:
await smn.db.run('add_book', { title, author });
The operation is the only way a visitor changes data. It is checked against the database when it is defined.
Each operation has its own limits per visitor per minute and per day.
A call carries a request key, so a retry of the same call never writes twice.
smn.db.runadds one for you; pass your own in{ requestKey }to retry safely.An operation can also read: it then returns rows.
Who can read which table
Not every table is readable by visitors.
A table the builder created for content you want to show is readable by visitors, and a visitor's SQL can read it.
A table that visitors write to through an operation, such as sign-ups or answers, is private by default: visitors cannot read it back, and neither can data derived from it. You and the AI builder always can.
A table that holds data derived from a private table cannot be made readable while its source is private.
To show visitors what was saved, for example a guest list or a leaderboard, switch the table to readable. Then every row in it can be read by anyone who can open the app.
You can see and switch Visitors can read per table in the configuration panel under Tables visitors can read.
If the AI builder built the data from private notes, SeeMyNotes warns you before you make the app available to more people. See Build an app with AI.
Change the database from an AI agent
An AI agent you connect over MCP can create the tables and write the data, and define the named operations, with the Studio apps permission. It sees the structure of every table (columns, which visitors can read, and the row count of each table visitors can read), but reads rows only from tables that visitors can read: a table that holds what visitors entered is never readable by an agent. When it changes data it gets counts back, never rows.
A change that would delete or rewrite data is not made: it waits for your approval in SeeMyNotes. That covers dropping a table or columns, removing 50 or more rows or all rows of a table, rewriting 200 or more rows, renaming or replacing tables, and a trigger that deletes or changes rows. Before an approved change, SeeMyNotes keeps a copy of the database as it was for 30 days; you can bring it back yourself under Database history. An operation it defines that lets visitors change, delete or replace rows (UPDATE, DELETE, REPLACE, or an insert that updates or replaces on conflict) waits for your approval too; an operation that only adds rows or reads is saved at once. See Manage your apps with an AI agent.
A change that would touch a table visitors write to (directly, through a trigger or by building an index on it) also waits for your approval, and the agent never learns rows, counts or error text about that table. Deleting in small chunks does not avoid approval: an agent's removals and rewrites of the last 24 hours add up, and the database before its first one of the day is kept for 30 days. Giving an agent Publish lets it make a table visitor-readable, which shows what visitors entered in it to every visitor; this needs your explicit go-ahead.
Database history: restore a kept copy
Before a change that removes data, SeeMyNotes keeps a copy of the whole database as it was, for 30 days. You find the copies in the configuration panel under Database history, newest first. Each copy says why it was kept and when, how many tables and rows it holds, its size and until when it is kept. For example:
Before Claude Code's change that removed data - 3 Dec 2026, 14:02 3 tables, 1,240 rows - 48 KB - Kept until 2 Jan
A copy is kept before:
a change that drops a table or columns, removes 50 or more rows or all rows of a table, rewrites 200 or more rows, or renames or replaces tables, whether you, the AI builder, the account assistant or an AI agent made it;
an AI agent's first removal or rewrite of the day;
an approved visitor operation that changes or removes rows;
a restore (the copy that undoes it).
To restore one, choose Restore next to it and confirm. SeeMyNotes asks, for example, "Restore the database as it was on 3 Dec at 14:02? The current data is kept as a copy for 30 days, so you can undo this."
The whole database goes back to the copy: every table and every row, including what visitors added or changed since then. You cannot restore a single table.
You can undo it. Before restoring, the database as it is now is kept as a new copy for 30 days. The result says until when, with an Undo button; the copy also appears in the list.
Visitors cannot read any table afterwards until you turn it on again. The result names the tables visitors could read before, with Let visitors read them again to turn them back on in one step. This stops a choice made for a newer table from applying to restored data you have not looked at.
Visitor operations that no longer fit the restored tables are named, so you can ask the AI builder to fix them.
During the restore, for a few seconds, visitors' reads and saves may wait or be asked to try again. Nobody ever reads a half-restored database.
What a copy does not hold: your app's secrets and variables, the visitor operations, which tables visitors can read, and the app's code (code has its own version history). Copies older than 30 days are gone, and no copy is made for changes that only add data. A copy larger than your plan's database size limit cannot be restored.
While an app is paused because your plan no longer includes Studio, its copies are still listed, but restoring waits until Studio is back. You can always download the database.
An AI agent can list the copies and ask for a restore, but never restores by itself: you approve it in SeeMyNotes, like a change that deletes data. See Manage your apps with an AI agent. The account assistant shows a restore on its own approval card. Step by step: Undo a change to an app's database.
Share data between your apps
Under App data, switch on Share this app's data with my other apps and your other apps and the AI builder can read this app's data, read-only. Another app reads it by naming the app:
const rows = await smn.db.all('SELECT title FROM books LIMIT 10', [], { app: '<app id>' });
smn.db.schema({ app: '<app id>' }) shows what the other app offers; its first answer includes the app id. The AI builder lists the apps that share data. Sharing is only between your own apps, never with other accounts. A switch-off takes effect at once. An app that is not public can read another app's shared data only while that other app is served publicly.
Storage and limits
The database has a maximum size, and all your apps share one storage quota that counts app files, data and checkpoints. Visitors' requests are limited per minute and per day. If you reach the storage quota, new saves are refused and nothing is deleted.
The current limits are shown on the plans and limits page.
Your data is kept safely: a write is confirmed to the app only once it has been stored durably. Deleting the app deletes its data. You can download the database as a SQLite file at any time; see History, checkpoints and export.
Related
Step by step: Add a database with search to an app
Step by step: Undo a change to an app's database