atproto record helpers
885 B
tinyrecord#
tinyrecord is a tiny set of helpers for interacting with atproto records.
Define a repo for an actor, then declare collections by NSID (optionally with a validator). Each collection exposes create, put, get, delete, list, and listAll.
Validators follow Standard Schema, a shared interface implemented by libraries like Zod, Valibot, and ArkType — so you can plug in whichever you prefer (or none).
import { createRepo } from "./tinyrecord.js";
const repo = createRepo({ actor: "jakelazaroff.com" });
const follow = repo.collection("com.example.follow");
await follow.create({
subject: "did:plc:...",
createdAt: new Date().toISOString(),
});
for await (const record of follow.listAll()) {
console.log(record.uri.href, record.value);
}
Use repo.collection(nsid).of(actor) to read another user's records.