Skip to content
Back to skills

Database

ASecurity

Read before writing an app that keeps data or has scheduled jobs, which it keeps in a database with this app.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 20, 2026
databasesgosqldatabase

Security analysis

A100/100

Pro scans all 10 files and shows the line behind each finding

Scanned November 20, 2026

npx -y skills add drevantonder/the-one-app --skill database --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Database?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Database
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/drevantonder-database/badge)](https://www.skillsdirectory.com/skills/drevantonder-database)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: database
description: Read before writing an app that keeps data or has scheduled jobs, which it keeps in a database with this app.
metadata:
  title: "Database"
  subtitle: "Where apps keep their data"
  about: "Gives every app here a database of its own, so what it keeps for you is yours, and what it keeps for a group is the group's."
  category: Admin
---

An app keeps its data in a database by requiring this app. The database is SQLite, kept in the app's own
artifact for whoever it runs for, so each user and each group has their own.

Its words:

- **Lease**: the record of which server writes a database for now. One server holds it at a time. Part of the database
  app.

    def requires, do: %{"database" => "to keep your notes"}

    @schema ["create table notes (id integer primary key, text text not null, at text not null)"]

    def call("add", %{"text" => text}, call) do
      database = OneCore.Call.app(call, "database")
      at = DateTime.to_iso8601(DateTime.utc_now(:second))

      database.transaction(call, @schema, fn db ->
        [%{"id" => id}] =
          database.query(db, "insert into notes (text, at) values (?, ?) returning id", [text, at])

        "Added note #{id}."
      end)
    end

- `transaction(call, schema, fun)` runs `fun` with the database and gives what it returns. What `fun` writes
  is kept all together or not at all: raise to keep none of it. Once it returns, what was written is safe in
  the bucket, and losing the server loses none of it.
- `query(db, sql, values)` runs one SQL statement with a `?` for each value, and gives its rows, each a map
  from a column's name to its value. `returning` gives back what an insert or an update made. A value is a
  number, text, `nil`, a boolean (kept as 1 or 0) or `{:blob, binary}`.
- `schema` is the statements that make the tables, in the order they were added. Each runs once on each
  database. To change the tables, add statements to the end, and leave the ones already deployed as they are.
- The database is the blobs under `log/` and `snapshot/` in the app's own artifact. Every other name there
  is the app's, for what isn't rows: a photo, a file.
- One server at a time writes a database, and a call that reaches another is passed on to it. So the tool may
  start again on another server, and `fun` may run more than once. Do everything that touches the database
  inside `fun`, and what reaches outside, such as sending a message, after `transaction` returns.
- An app's scheduled jobs (its `jobs/0`) are called by the server writing its database, and when each last
  ran is kept there too, in the table `database_scheduled`. A job's call marks that it ran in its own first
  transaction, so what it wrote and its having run are kept together or not at all: a server that takes over
  makes the call again only if neither was. So a job does its work in one transaction, in the process its
  tool is called in, and what reaches outside after `transaction` returns, which then happens at most once.
  A job that makes no transaction is marked when its call ends, and may be called again after a failover.

Files in this skill

  • SKILL.md3.1 KB
  • icon.svg10.4 KB
  • server/checksums.json1.2 KB
  • server/database.ex7.2 KB
  • server/database/lease.ex29.8 KB
  • server/database/log.ex5.1 KB
  • server/nif/sqlite.ex1 KB
  • server/nif/sqlite/Cargo.toml470 B
  • server/nif/sqlite/build.rs743 B
  • server/nif/sqlite/src/lib.rs4.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in databases →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.