Hosna Qasmei
Hosna Qasmei
CCConvex Community
Created by Hosna Qasmei on 9/17/2024 in #support-community
Resources for Implementing User Roles
Was thinking about saving the role in the clerk meta data and the convex table
6 replies
CCConvex Community
Created by Hosna Qasmei on 9/17/2024 in #support-community
Resources for Implementing User Roles
Would this work if I wanted an admin user, a staff user, a base user? I want each would see a different dashboard
6 replies
CCConvex Community
Created by Hosna Qasmei on 7/17/2024 in #support-community
Trying to add rate limiting to newsletter sign up
Hey @ian , I appreciate your response. Yup did that method instead using https://www.google.com/recaptcha/ @Web Dev Cody clarified it for me πŸ˜… The same reasoning you mentioned, still vulnerable to DDOSing if I did it the rate limiting way. Thank you!
4 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
Ah yes that article looks like it’s it, let me take a look and try it thanks @lee @erquhart
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
Yeah πŸ˜…
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
so the selected filter is an array of strings dont think I can do q.contains, no sure what other way there is im trying to filter based on tags, so if the tab is in tabs of that item I want to include it
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
was the last comment just to stick with filter the frontend since I need access to all the data?
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
@Web Dev Cody i wish I was trying to just paginate lol, I want to filter and sort as well from the backend if possible
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
right
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
okay gotcha, but you notice when you filter to another tab the load spinner shows up so im not sure if that's filtering based of the query and paginating to look for more results because all the data isnt there
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
So I initially did the sort/filter the in the frontend approach it worked for me on desktop but mobile i was coming across this issue https://github.com/vercel/next.js/issues/34455 so to avoid it i wanted to do infinite scrolling
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
yup, filtering on the front end
const { results, status, loadMore } = usePaginatedQuery(
api.portfolios.getPortfolios,
{
sortType: selectedSort || 'recentlyAdded',
filterType: selectedFilter || 'All',
},
{ initialNumItems: 6 },
);

const filteredData =
selectedFilter === 'All' || selectedFilter === null || !results
? results
: results.filter(
(portfolio) =>
portfolio.tags &&
portfolio.tags.map((tag) => `${tag}s`).includes(selectedFilter),
);
const { results, status, loadMore } = usePaginatedQuery(
api.portfolios.getPortfolios,
{
sortType: selectedSort || 'recentlyAdded',
filterType: selectedFilter || 'All',
},
{ initialNumItems: 6 },
);

const filteredData =
selectedFilter === 'All' || selectedFilter === null || !results
? results
: results.filter(
(portfolio) =>
portfolio.tags &&
portfolio.tags.map((tag) => `${tag}s`).includes(selectedFilter),
);
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
if you go here, and select one of the options that isn't All it gets glitchy
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
sorting is fine, it's the filtering that's giving the issue
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
no it's the opposite
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
okay so here is my dilemma
export const listWithTransformation = query({
args: { paginationOpts: paginationOptsValidator },
handler: async (ctx, args) => {
const results = await ctx.db
.query("messages")
.order("desc")
.paginate(args.paginationOpts);
return {
...results,
page: results.page.map((message) => ({
author: message.author.slice(0, 1),
body: message.body.toUpperCase(),
})),
};
},
});
export const listWithTransformation = query({
args: { paginationOpts: paginationOptsValidator },
handler: async (ctx, args) => {
const results = await ctx.db
.query("messages")
.order("desc")
.paginate(args.paginationOpts);
return {
...results,
page: results.page.map((message) => ({
author: message.author.slice(0, 1),
body: message.body.toUpperCase(),
})),
};
},
});
for this example, results only returns a subset of the data because of pagination. Lets say I want to filter and sort from All the data in the messages table . If I do it through this example, it will only do i from that subset from results right? how would i do it the way I need to
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
Ah yes, I thouhght I saw that somewhere. Thanks @Michal Srb !
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
Wow paginated query is amazing! Wanted to know if you can help, with in the paginated query I want to sort and filter if possible. This is what I have right now, only the sorting. Not sure if it's right. Wanted to also do filtering,

export const getPortfolios = query({
args: {
paginationOpts: paginationOptsValidator,
sortType: v.string(),
filterType: v.string(),
},
handler: async (ctx, args) => {
const { paginationOpts, sortType, filterType } = args;

// TODO:Filtering

// Sorting
if (sortType === 'recentlyAdded') {
return await ctx.db
.query('portfolios')
.filter((q) => q.eq(q.field('tags'), [filterType])) // Doesn't work
.order('desc')
.paginate(paginationOpts);
} else if (sortType === 'mostPopular') {
return await ctx.db
.query('portfolios')
.filter((q) => q.eq(q.field('tags'), [filterType])) // Doesn't work
.withIndex('by_favoritesCount')
.order('desc')
.paginate(paginationOpts);
} else if (sortType === 'alphabetical') {
return await ctx.db
.query('portfolios')
.filter((q) => q.eq(q.field('tags'), [filterType])) // Doesn't work
.withIndex('by_name')
.order('asc')
.paginate(paginationOpts);
} else {
return await ctx.db.query('portfolios').paginate(paginationOpts);
}
},
});

export const getPortfolios = query({
args: {
paginationOpts: paginationOptsValidator,
sortType: v.string(),
filterType: v.string(),
},
handler: async (ctx, args) => {
const { paginationOpts, sortType, filterType } = args;

// TODO:Filtering

// Sorting
if (sortType === 'recentlyAdded') {
return await ctx.db
.query('portfolios')
.filter((q) => q.eq(q.field('tags'), [filterType])) // Doesn't work
.order('desc')
.paginate(paginationOpts);
} else if (sortType === 'mostPopular') {
return await ctx.db
.query('portfolios')
.filter((q) => q.eq(q.field('tags'), [filterType])) // Doesn't work
.withIndex('by_favoritesCount')
.order('desc')
.paginate(paginationOpts);
} else if (sortType === 'alphabetical') {
return await ctx.db
.query('portfolios')
.filter((q) => q.eq(q.field('tags'), [filterType])) // Doesn't work
.withIndex('by_name')
.order('asc')
.paginate(paginationOpts);
} else {
return await ctx.db.query('portfolios').paginate(paginationOpts);
}
},
});
here is my schema for portfolios
export default defineSchema({
portfolios: defineTable({
name: v.string(),
link: v.string(),
tags: v.optional(v.array(v.string())),
image: v.id('_storage'),
favoritesCount: v.optional(v.number()),
})
.index('by_favoritesCount', ['favoritesCount'])
.index('by_name', ['name'])
.index('by_tags', ['tags']),
...
export default defineSchema({
portfolios: defineTable({
name: v.string(),
link: v.string(),
tags: v.optional(v.array(v.string())),
image: v.id('_storage'),
favoritesCount: v.optional(v.number()),
})
.index('by_favoritesCount', ['favoritesCount'])
.index('by_name', ['name'])
.index('by_tags', ['tags']),
...
64 replies
CCConvex Community
Created by Hosna Qasmei on 7/1/2024 in #support-community
What is the best way to implement infinite scrolling with Convex
yes it does, just looked it up wasn't aware of it πŸ˜… will try it, thank you!
64 replies