Mordsith
Mordsith
CCConvex Community
Created by Mordsith on 9/28/2024 in #support-community
Type inference issue with newly added routes
No description
5 replies
CCConvex Community
Created by Mordsith on 9/28/2024 in #support-community
Custom query with default argument
I want to write a custom query that adds a default argument.
export const organizationAdminQuery = customQuery(
query,
customCtx(async (ctx) => {
const userId = await getAuthUserIdOrFail(ctx);
return { ...ctx, userId };
})
);

// These queries are only available to the organization admin
export const orgAdminQuery = organizationAdminQuery({
args: { organizationId: v.id("organization") },
handler: async (ctx, { organizationId }) => {
return getOrganizationAdmins(organizationId)
},
});
export const getOrganizationSponsorsQuery = organizationAdminQuery({
args: { organizationId: v.id("organization") },
handler: async (ctx, { organizationId }) => {
return getOrganizationAdmins(organizationId)
},
});
export const organizationAdminQuery = customQuery(
query,
customCtx(async (ctx) => {
const userId = await getAuthUserIdOrFail(ctx);
return { ...ctx, userId };
})
);

// These queries are only available to the organization admin
export const orgAdminQuery = organizationAdminQuery({
args: { organizationId: v.id("organization") },
handler: async (ctx, { organizationId }) => {
return getOrganizationAdmins(organizationId)
},
});
export const getOrganizationSponsorsQuery = organizationAdminQuery({
args: { organizationId: v.id("organization") },
handler: async (ctx, { organizationId }) => {
return getOrganizationAdmins(organizationId)
},
});
I would like to add an organizationId argument to this custom query so that every consumer of this custom query won't need an organizationId in the query args. I'm trying to achieve this to avoid the repeated organizationId in the args param
export const getOrganizationSponsorsQuery = organizationAdminQuery({
args: {},
handler: async (ctx, { organizationId }) => {
return getOrganizationAdmins(organizationId)
},
});
export const getOrganizationSponsorsQuery = organizationAdminQuery({
args: {},
handler: async (ctx, { organizationId }) => {
return getOrganizationAdmins(organizationId)
},
});
I got this working using another approach but I'll like to know if this can be done directly with customQuery
5 replies
CCConvex Community
Created by Mordsith on 9/20/2024 in #support-community
Convex Auth Typescript Error with Vercel
No description
9 replies
CCConvex Community
Created by Mordsith on 8/6/2024 in #support-community
Conex Auth fatal error
No description
4 replies
CCConvex Community
Created by Mordsith on 8/3/2024 in #support-community
Convex Auth e2e test with Playwright
I currently use the Email OTP provider, I couldn't figure a way to get verification code within the test environment without exposing this code somewhere in memory that is globally available but unsafe. Migrating from Clerk, Clerk solved this by doing 2 things - Every email login with clerk_test in the email is treated as a fake user.... For example michael+clerk_test@example.com - Every user with that kind of email address can verify auth with 424242 (This code works for only users with clerk_test in their email As a fallback, I switched to using Anonymous Provider for test envoronment but it would be beneficial if we can test actual authentication flow like a real user. @Michal Srb
1 replies
CCConvex Community
Created by Mordsith on 7/12/2024 in #support-community
import.meta in Convex
No description
2 replies
CCConvex Community
Created by Mordsith on 7/6/2024 in #support-community
ConvexTest setup error
No description
5 replies
CCConvex Community
Created by Mordsith on 7/2/2024 in #support-community
Schedulers with priority
It would be nice if the schedulers can have a priority to control how functions are executed. In my scenario, I'm consumin a Webhook from Microsoft Azure that calls my convex route which triggers a scheduled function (rate Limited / 1minute). There were 10 failed webhooks, the 3rd party provider keeps retrying the failed webhook when a new request comes in. For example, a new user makes a request, expected to receive a result in 1minute (rateLimit), however, the provider automatically retries the previous webhooks that failed in random order. Each of this run waits for 1minute thereby making the new user wait 10 minute before his request is processed. If there was a way to prioritize the scheduler + rateLimit, HIGH, LOW, MEDIUM or something close so that even when we have 100 items scheduled to run, it starts with functions with HIGH priorities first, assuming the failed request was set with LOW priority. With this in place, failed webhooks won't stall results for new users as they'll be processed later.
7 replies
CCConvex Community
Created by Mordsith on 6/19/2024 in #support-community
Database seed with 70,000 items
I've been trying to get past this error: You have an outstanding query call. Operations should be awaited or they might not run. Not awaiting promises might result in unexpected failures. See https://docs.convex.dev/functions/actions#dangling-promises for more information. This is my code, I've tried writing it in many ways I have a npm script that seeds data into a database, this seed is an internal action that is meant to fetch a JSON response from an external source, the size of the JSON response is approximately 7MB. When this action runs, I want to run a mutation that adds each of the item to a table. I'm not able to get past this issue with Promises.
31 replies
CCConvex Community
Created by Mordsith on 6/6/2024 in #support-community
Handling Rate Limits with Convex Scheduler
If I were to mirror a queue that runs exactly like a setInterval, how do I do that? Scenario. I want to call a third-party service that has a 1req per minute rate limit. With most queue workers, using a simple configuration, you can specify that you want the worker to run jobs every 1 minute to beat the rate-limiting problem. If 10,000 users make a request at once, no problem since all this will be in the queue and the worker will process it every minute. Hw do I configure a scheduler to work this way? Imagine 10, 000 users would hit the function to be scheduled. I want to process this using FIFO at set intervals
9 replies
CCConvex Community
Created by Mordsith on 5/8/2024 in #support-community
Sort paginated items
I have this schema
export const participantsSchema = defineTable({
sessionId: v.id("session"),
searchable: v.optional(v.string()),
userProfileId: v.optional(v.id("userProfiles")),
invitedBy: v.optional(v.id("userProfiles")),
role: sessionRoleEnumValidator
})
.index("by_session_id", ["sessionId"])
.index("by_session_role", ["sessionId", "role"])
.index("by_user_profile_id", ["userProfileId"])
.index("by_user_profile_role", ["userProfileId", "role"])
.index("by_invite", ["invitedBy", "userProfileId"])
.index("by_invite_role", ["invitedBy", "userProfileId", "role"])
.index("by_session_and_user", ["sessionId", "userProfileId"])
.index("by_searchable_field", ["searchable"])
.searchIndex("by_searchable", {
searchField: "searchable",
filterFields: ["userProfileId", "sessionId", "role"],
});
export const participantsSchema = defineTable({
sessionId: v.id("session"),
searchable: v.optional(v.string()),
userProfileId: v.optional(v.id("userProfiles")),
invitedBy: v.optional(v.id("userProfiles")),
role: sessionRoleEnumValidator
})
.index("by_session_id", ["sessionId"])
.index("by_session_role", ["sessionId", "role"])
.index("by_user_profile_id", ["userProfileId"])
.index("by_user_profile_role", ["userProfileId", "role"])
.index("by_invite", ["invitedBy", "userProfileId"])
.index("by_invite_role", ["invitedBy", "userProfileId", "role"])
.index("by_session_and_user", ["sessionId", "userProfileId"])
.index("by_searchable_field", ["searchable"])
.searchIndex("by_searchable", {
searchField: "searchable",
filterFields: ["userProfileId", "sessionId", "role"],
});
I want to query like this but give the users ability to sort in ascending / descending order based on the searchable index.
const data = await ctx.db
.query("participants")
.withIndex("by_user_profile_role", (q) =>
q.eq("userProfileId", userProfileId).eq("role", defaultRole)
)
.order("desc")
.paginate(paginationOpts);
const data = await ctx.db
.query("participants")
.withIndex("by_user_profile_role", (q) =>
q.eq("userProfileId", userProfileId).eq("role", defaultRole)
)
.order("desc")
.paginate(paginationOpts);
When I replace:
.withIndex("by_user_profile_role", (q) =>
q.eq("userProfileId", userProfileId).eq("role", defaultRole)
)
.withIndex("by_user_profile_role", (q) =>
q.eq("userProfileId", userProfileId).eq("role", defaultRole)
)
with:
.withIndex("by_searchable")
.withIndex("by_searchable")
sort works as expected but I can't use multiple index, I need to use the existing index while allowing users to sort based on the searchable field
2 replies
CCConvex Community
Created by Mordsith on 4/30/2024 in #support-community
Use jsx-email within convex
No description
7 replies
CCConvex Community
Created by Mordsith on 3/13/2024 in #support-community
Authentication Error and SSR with Next.JS
No description
4 replies
CCConvex Community
Created by Mordsith on 2/22/2024 in #support-community
IndexNamesNotUnique
All my tables have unique index names but I get this error when I try to dev
7 replies