Paginated list
List records from the lexicon’s target collection, with cursor pagination and an optional DID filter.
Trigger: xrpc.query:<nsid>. Needs: happyview-db.
local db = require("happyview.db")
function handle(input, ctx) local limit = tonumber(input.limit) or 20 if limit > 100 then limit = 100 end
return db.records(ctx.collection) :did(input.did) :limit(limit) :cursor(input.cursor) :run()endJavaScript
Section titled “JavaScript”import db from "happyview.db";
export default function handle(input, ctx) { const limit = Math.min(Number(input.limit) || 20, 100);
return db.records(ctx.collection) .did(input.did) .limit(limit) .cursor(input.cursor) .run();}TypeScript
Section titled “TypeScript”import db from "happyview.db";
interface Input { did?: string; limit?: string | number; cursor?: string;}
export default function handle(input: Input, ctx: { collection: string }) { const limit = Math.min(Number(input.limit) || 20, 100);
return db.records(ctx.collection) .did(input.did) .limit(limit) .cursor(input.cursor) .run();}How it works
Section titled “How it works”- Read
limitfrom the query string, defaulting to 20 and capping at 100. Query parameters can arrive as strings, so the script converts it to a number. - Build a
db.recordschain on the target collection. A step given no value is skipped, so a request withoutdidorcursorneeds no branching. In JavaScript the argument list ends at the firstundefined, which has the same effect. run()returns{ records, cursor }. Each record is an envelope, andcursoris present when there are more records. In JavaScript and TypeScript,run()returns a promise;handlereturns it and HappyView awaits it.
GET /xrpc/xyz.statusphere.listStatuses?limit=10&did=did:plc:abcGET /xrpc/xyz.statusphere.listStatuses?limit=10&cursor=<cursor from the previous page>
