Building an app

Write and read

Write into the user’s repo, on their PDS. Read back through the platform, with a query.

Write

Write into the user’s repo, on their PDS. The SDK’s put writes, then hints pub.techne.draft.sync.indexRecord {uri} so the record is indexed at once rather than when the relay brings it. After a delete on the PDS, hint the same uri: the platform reads the PDS’s proof it is gone and drops it (a pending type’s deletes arrive no other way). npx techne-sdk types <nsid> prints code types for any type.

Read

pub.techne.draft.query.listRecords, getRecords, countRecords and pub.techne.draft.query.composeRecords take a query as a JSON string, for example:

{"where":{"all":[{"type":{"is":"<nsid>"}},{"author":{"is":"$viewer"}}]}}

Short form, as other sections write it: {type is X, author is $viewer}. Besides type and author, a query filters and orders on roles (start, end, location, text, references, category), which a type’s query document maps to its fields. A leaf names one role and one operator: is, in (a list), after and before (RFC 3339 or $now), near ({point: “lat,lng”, within: “5km”}, at most 50km) and matches (words of the text); all, any and not combine leaves, and order names one role, a near/matches measure or shuffle. $now and $viewer are the platform’s; pass your own $params in params. The full grammar is the pub.techne.draft.query lexicon (registry.getType {nsid: “pub.techne.draft.query”}).

State two people share

A loan, a booking, a handover: each person writes only in their own repo, and the state is derived from the pair. To lend a tool, the lender writes a loan (subject the listing, borrower a DID); the borrower writes an acceptance whose subject is the loan’s uri. “On loan” means both exist (a loan alone is an offer). The return is the lender’s own return naming the loan; either side withdraws by deleting their record. Map subject to the references role and query both types by it.

Limits

Writes have a per-account rate (429). Indexing of a community or requested type has daily budgets (by default 5000 records per author and 200000 per type); a record over budget is skipped, and pub.techne.draft.query.listRejections names it with reason budget.