djbalin
djbalin
CCConvex Community
Created by djbalin on 12/19/2024 in #support-community
[Backup & restore]: Force overwrite
Great thanks! LMK if you would like my deployment URL or more info for debugging 😊
4 replies
CCConvex Community
Created by djbalin on 12/5/2024 in #support-community
Union schema: no type inference?
@ballingt Is there somewhere that we can follow the status of feature requests or view what's in your pipeline? πŸ™‚
3 replies
CCConvex Community
Created by David Alonso on 11/2/2024 in #support-community
Mutation error: `Returned promise will never resolve` caused by triggers
Could calculating/populating your aggregates e.g. once every 24 hours work in your situation? That's what we are doing in our project. We have some aggregates on a table that runs very hot write-wise, so we decided to not attach an aggregate-updating trigger to that table due to the high write volume. Instead we just update our aggregates with new documents from the last 24 hours once nightly. Of course this only works if you don't need very real-time aggregates.
54 replies
CCConvex Community
Created by David Alonso on 11/29/2024 in #support-community
Exponential number of indexes required?
I second the notions above and encourage what you mention here @Indy: Generally update docs to nudge people towards patterns that help people build scalable apps. This is a balance, because the core docs are very focused on "this is how the api works." For me, this nudging and opinionation is one of the main reasons I've grown to love Convex. In our small startup team of 2 developers, for example, both of us are talented, but neither has a lot of experience in building and scaling production apps. We love that Convex is both a great product and a team that seems intent on communicating best practices and sharing their experience. We're excited to leverage you guys' decades of experience on huge projects through stack posts, nudging in the docs, and here on Discord. Don't be afraid to be opinionated or provide suggestions!!! It's of incredible valuable for all of us - both for strictly learning to use Convex and its API, but, much more valuably, how to think about building a system, and which common problems Convex alleviates. The API/SDK is so well-documented that it's very easy to deviate from your blanket recommendations whenever that makes sense for a specific use-case. We gobble up and learn from all your recommendations, stack posts, Discord comments, etc., and we lean against those as much as we can, and whenever our lack of experience leaves us in doubt. But there is no lock-in: you do a good job of stating that these are recommendations and outlining tradeoffs, so we confidently deviate from these whenever relevant for our product. What you're doing is a huge gift to all junior/mid developers. Convex sits at an awesome abstraction level. Be opinionated and provide suggestions such that more junior developers can get onboard quickly and will feel safe in mentally offloading some tough decisions to you guys. By definition, experienced devs will find what they're looking for, and will probably also learn a thing or two in the process!
46 replies
CCConvex Community
Created by djbalin on 12/4/2024 in #support-community
Ignoring _generated in pull requests/git diff
Thanks @jamwt , good find. Now the diff is collapsed/unrendered by default, that's nice :)) thanks
7 replies
CCConvex Community
Created by David Alonso on 11/29/2024 in #support-community
Exponential number of indexes required?
Interesting, would like to know this as well. I guess at least you could create one aggregate that's a "chain" of some of your filters: a->b->c->d->.. and you can then query that aggregate by any number of filters beginning in the chain from a, if Im not mistaken
46 replies
CCConvex Community
Created by Doogibo on 11/29/2024 in #support-community
Conditionally Building Queries
I battled with something similar to this a few weeks ago as well. https://discord.com/channels/1019350475847499849/1282852743689535548/1301665342770249809 There's some discussion about it in this thread and a link to a lil' repo I made with my findings. Not done or thorough at all, but maybe some of its useful to you!
10 replies
CCConvex Community
Created by entropy on 5/9/2024 in #support-community
Failed to load url with convex-test
Works now after updating convex, thanks man! ☺️
28 replies
CCConvex Community
Created by entropy on 5/9/2024 in #support-community
Failed to load url with convex-test
I'm sure you understand it better than I do πŸ˜‚ thanks man. Guess I should pay more attention to dependency warnings in the future!
28 replies
CCConvex Community
Created by entropy on 5/9/2024 in #support-community
Failed to load url with convex-test
@lee β”œβ”€ convex-helpers@npm:0.1.56 β”œβ”€ convex-test@npm:0.0.33 β”œβ”€ convex@npm:1.16.3 Could that be the problem, that the newest Convex version is 1.16.6 and test depends on that?
28 replies
CCConvex Community
Created by entropy on 5/9/2024 in #support-community
Failed to load url with convex-test
No description
28 replies
CCConvex Community
Created by CPTRedHawk on 9/25/2024 in #support-community
High bandwidth consumption
Yes I think you could use a cron job for this, see Convex docs, it's very easy to set up: https://docs.convex.dev/scheduling/cron-jobs But yes as you point out, the potential problem/downside is then that the scoreboard is not truly real-time/live. Are you making a real-time PvP game?
42 replies
CCConvex Community
Created by CPTRedHawk on 9/25/2024 in #support-community
High bandwidth consumption
Good morning brother. What about the suggestion to calculate the entire leaderboard every X minutes and storing each user's rank directly on their document? Would that not be OK for you? I really think this could cut your bandwidth consumption dramatically Generate leaderboard:
export const generateLeaderboard = mutation({
handler: async (ctx) => {
let rank = 1;
for await (const user of ctx.db
.query("user")
.withIndex("by_points")
.order("desc")) {
console.log(rank);
await ctx.db.patch(user._id, {
rank: rank,
});
rank += 1;
}
},
});
export const generateLeaderboard = mutation({
handler: async (ctx) => {
let rank = 1;
for await (const user of ctx.db
.query("user")
.withIndex("by_points")
.order("desc")) {
console.log(rank);
await ctx.db.patch(user._id, {
rank: rank,
});
rank += 1;
}
},
});
Get rank of current user:
export const getRankByUserId = query({
args: {
userId: v.id("user"),
},
handler: async (ctx, { userId }) => {
const user = await ctx.db.get(userId);
if (user === null)
throw new ConvexError(`User with id ${userId} not found`);
return user.rank;
},
});
export const getRankByUserId = query({
args: {
userId: v.id("user"),
},
handler: async (ctx, { userId }) => {
const user = await ctx.db.get(userId);
if (user === null)
throw new ConvexError(`User with id ${userId} not found`);
return user.rank;
},
});
42 replies
CCConvex Community
Created by CPTRedHawk on 9/25/2024 in #support-community
High bandwidth consumption
ok sorry I'm blind, @ballingt suggested this above..
42 replies
CCConvex Community
Created by CPTRedHawk on 9/25/2024 in #support-community
High bandwidth consumption
Actually what the frick am I talking about, Convex maintains this automatically with the index on points??? Just traverse this: the first index would be rank 1, the last index would be the last rank?
42 replies
CCConvex Community
Created by CPTRedHawk on 9/25/2024 in #support-community
High bandwidth consumption
You could implement "Your rank is updated every X minutes" and set up a cron job to calculate the entire leaderboard every X minutes and store each user's rank on their document. Maybe a rough idea could be this (I'm not very strong in time complexities, just take this as a guess): - Insert all scores into a HashMap, O(n) - Sort this HashMap by scores O(n*logn) - Iterate through this array once and set rank of user equal to the index O(n)
42 replies
CCConvex Community
Created by TwendyKirn on 9/22/2024 in #support-community
Quering random row
Absolutely yes!! 😍 We've discussed why .random() isn't in Convex yet already, and concluded that you probably want to not bloat it prematurely with all sorts of specific use cases before there is too much request for it. But this would be great!!
20 replies
CCConvex Community
Created by djbalin on 9/9/2024 in #support-community
[Convex Auth]: convexAuth() causes "Type instantiation is excessively deep and possibly infinite."
We are still experiencing this issue. If we comment out our auth.ts file, the excessively deep-warning disappears. Any ideas @Michal Srb or @sshader ? Thanks 🌞
3 replies
CCConvex Community
Created by TwendyKirn on 9/22/2024 in #support-community
Quering random row
No description
20 replies
CCConvex Community
Created by djbalin on 9/23/2024 in #support-community
Control Convex env variables output location
I think maybe we solved it by following the standard .env file resolution that Expo uses: https://github.com/bkeepers/dotenv/blob/c6e583a/README.md#what-other-env-files-can-i-use We changed our env.development --> env.local.development and the same for production. Now our bundler correctly prioritizes these over env.local πŸ™‚ Maybe this is the intended approach then, and Convex dev spitting out stuff into env.local is no problem?
4 replies