Integrate Frontend
Querying
Query operators — where, orderBy, with, select, pagination.
QUESTPIE provides type-safe query operators derived from your field definitions. Every operator is available on both the server and client.
Where Clauses
Equality
// Exact match
where: {
status: "published";
}
// Boolean
where: {
isActive: true;
}
// Relation by ID
where: {
barber: "barber-id-123";
}Comparison
// Greater than / less than
where: { price: { gt: 1000 } }
where: { price: { gte: 1000, lt: 5000 } }
// Date ranges
where: {
scheduledAt: {
gte: new Date("2025-03-01"),
lte: new Date("2025-03-31"),
},
}Text Operations
where: {
title: {
contains: "hello";
}
}
where: {
email: {
startsWith: "john";
}
}
where: {
slug: {
endsWith: "-draft";
}
}In
where: { status: { in: ["draft", "published"] } }
where: { id: { in: ["id1", "id2", "id3"] } }Operators by Field Type
| Field Type | Operators |
|---|---|
text | equals, contains, startsWith, endsWith, in |
number | equals, gt, gte, lt, lte, in |
boolean | equals |
date / datetime | equals, gt, gte, lt, lte |
select | equals, in |
relation | equals (by ID) |
OrderBy
orderBy: {
createdAt: "desc";
}
orderBy: {
name: "asc";
}
orderBy: {
price: "asc";
}Pagination
const page1 = await client.collections.posts.find({
limit: 10,
offset: 0,
});
// page1.docs — first 10 records
// page1.totalDocs — total count
const page2 = await client.collections.posts.find({
limit: 10,
offset: 10,
});Relations (with)
Include related data:
const barber = await client.collections.barbers.findOne({
where: { id: "abc" },
with: {
services: true,
// Nested
appointments: {
with: {
service: true,
},
},
},
});Select
Pick specific fields:
const posts = await client.collections.posts.find({
select: { id: true, title: true, status: true },
});
// Only id, title, status returnedServer-Side Querying
Same operators work in hooks, routes, and jobs:
handler: async ({ collections }) => {
const active = await collections.barbers.find({
where: { isActive: true },
orderBy: { name: "asc" },
with: { services: true },
});
return active;
};Related Pages
- Fields — Field types determine available operators
- Relations — Relation queries
- Type Inference — Query types