How it works — query on-chain PDAs with @curvhex/orm
// 1. Define your Anchor account schema
export const TaskModel = defineModel({
discriminator: anchor("Task"),
fields: {
owner: { type: "publicKey" },
taskId: { type: "u64" },
title: { type: "string", maxLen: 64 },
priority: { type: "u8" },
status: { type: "u8" },
createdAt: { type: "i64" },
},
});
// 2. Create the ORM (works with any RPC endpoint)
const orm = new CurvhexORM({
connection: new Connection("https://api.devnet.solana.com"),
programId: PROGRAM_ID,
models: { Task: TaskModel },
});
// 3. Query like Prisma — no manual memcmp byte math
const tasks = await orm.models.task.findMany({
where: { status: 1 }, // filter in_progress tasks
});
// Aggregate across all accounts
const stats = await orm.models.task.aggregate({
_count: true,
_sum: { taskId: true },
});
// Group by field
const byStatus = await orm.models.task.groupBy({
by: ["status"],
_count: true,
});On-chain stats
Total Tasks
0
To Do
0
In Progress
0
Done
0