Web Dev Cody
Web Dev Cody
Explore posts from servers
CCConvex Community
Created by Wayne on 12/17/2024 in #show-and-tell
The Complete Convex Crash Course
It’s a good one ^ thanks for sharing
2 replies
CCConvex Community
Created by Web Dev Cody on 10/5/2024 in #support-community
Convex in stackblitz
has anyone gotten convex working in stackblitz
5 replies
CCConvex Community
Created by Web Dev Cody on 10/2/2024 in #support-community
Understanding usePaginatedQuery
or just don't use ids and instead use proper dates
23 replies
CCConvex Community
Created by Web Dev Cody on 10/2/2024 in #support-community
Understanding usePaginatedQuery
I could also probably just do order('desc') so that id 1 is the oldest I think
23 replies
CCConvex Community
Created by Web Dev Cody on 10/2/2024 in #support-community
Understanding usePaginatedQuery
const PAGE_SIZE = 5;

export const getPosts = query({
args: {
page: v.number(),
},
handler: async (ctx, args) => {
const startId = (args.page - 1) * PAGE_SIZE + 1;

const page = await ctx.db
.query("blogPosts")
.withIndex("incrementingId_index", (q) =>
q.gte("incrementingId", startId)
)
.take(PAGE_SIZE);

return page;
},
});
const PAGE_SIZE = 5;

export const getPosts = query({
args: {
page: v.number(),
},
handler: async (ctx, args) => {
const startId = (args.page - 1) * PAGE_SIZE + 1;

const page = await ctx.db
.query("blogPosts")
.withIndex("incrementingId_index", (q) =>
q.gte("incrementingId", startId)
)
.take(PAGE_SIZE);

return page;
},
});
23 replies
CCConvex Community
Created by Web Dev Cody on 10/2/2024 in #support-community
Understanding usePaginatedQuery
sorry I've modified since posting
23 replies
CCConvex Community
Created by Web Dev Cody on 10/2/2024 in #support-community
Understanding usePaginatedQuery
run it, then just do a take(PAGE_SIZE)
23 replies
CCConvex Community
Created by Web Dev Cody on 10/2/2024 in #support-community
Understanding usePaginatedQuery
going to add this export const addAutoIncrementingIdToPosts = internalMutation({ args: {}, async handler(ctx) { const posts = await ctx.db.query("blogPosts").order("desc").collect(); await Promise.all( posts.map((post, index) => ctx.db.patch(post._id, { incrementingId: index + 1 }) ) ); }, });
23 replies