Charliehub · by A.N.D.Why

Building block 9 · Going further

Data & storage

Your extension doesn't need a storage system of its own. Charlie gives it three places to keep the person's data: a folder on this computer, the person's remote storage, and the person's own database. The data stays theirs, wherever it lives.

What you'd use it for

The three places

In a handlerWhere the data lives
ctx.persistenceA folder on this computer, ~/ClaudeShared/charlie/data/. Always on. Nothing to declare.
ctx.remotePersistenceWhichever extension holds the remotePersistence role. Today that is hub-persistence, which stores in the person's hub.
ctx.rdbmsPgA PostgreSQL database, through whichever extension holds the rdbmsPg role. Today that is hub-database.

Both document stores work the same way: one JSON document per key, grouped under a collection name. They offer get, set, update, patchText, append, list and delete.

In your manifest

Using storage needs nothing in the manifest. Providing it does. This is from hub-database, which provides the database:

hub-database / manifest.json (trimmed)
{
  "name": "hub-database",
  "role": "rdbmsPg",
  "rdbms": { "module": "./handlers/rdbms.js" },
  "connections": [
    { "name": "hub", "authType": "oauth2-discovery",
      "transport": "rest-client" }
  ]
}

And this is how its own query tool reaches the database, the same way any other extension would:

hub-database / handlers/query.js (one line)
r = await ctx.rdbmsPg.query(sql, params, { maxRows })

The hub-persistence extension (Finder) provides remote storage with "role": "remotePersistence" and "persistence": { "module": "./handlers/persistence.js" }.

What each part means

FieldWhat it does
persistence.moduleFor a remotePersistence provider. The file exports get, set, update, patchText, append, list and delete, each taking (ctx, collection, key, ...).
rdbms.moduleFor a database provider. The file exports query, describe, import and info. Required with the rdbmsPg role.

Things to know

See it in

Every field in detail: persistence and rdbms in the reference.