gabrielw
gabrielw
CCConvex Community
Created by gabrielw on 5/1/2025 in #support-community
Clerk + Convex + TanStack Start setup
marking resolved. issue, believe it or not on development, my env file was .env.local, once i changed it to .env, it worked
3 replies
CCConvex Community
Created by gabrielw on 2/3/2025 in #show-and-tell
Crowdfunded Concerts with Tourest
Yeah! That was awesome. Super excited about everything. It’s been really fun working on this
5 replies
CCConvex Community
Created by Tom Redman on 1/10/2025 in #support-community
Is this typically a bad practice? v.union(v.id("thisList"), v.id("thatList"))
yeah, the coolest thing too is that this not only makes my front end forms much cleaner, but I'm also able to handle conditional logic in a single mutation by checking the type used in the payload. Super clean, really appreciate the tip
15 replies
CCConvex Community
Created by Tom Redman on 1/10/2025 in #support-community
Is this typically a bad practice? v.union(v.id("thisList"), v.id("thatList"))
glad I stumbled upon this support issue - was able to apply this discriminated union approach myself for a mutation with 3 different permutations of inputs.
export const vEventTicketingUpdate = v.union(
v.object({
type: v.literal("venueWithTicketing"),
ticketingInfo: vTicketingInfo,
geoAddressJson: vGeoAddressJson,
geoLatitude: v.string(),
geoLongitude: v.string(),
}),
v.object({
type: v.literal("ticketing"),
ticketingInfo: vTicketingInfo,
}),
v.object({
type: v.literal("venue"),
geoAddressJson: vGeoAddressJson,
geoLatitude: v.string(),
geoLongitude: v.string(),
})
);
export const vEventTicketingUpdate = v.union(
v.object({
type: v.literal("venueWithTicketing"),
ticketingInfo: vTicketingInfo,
geoAddressJson: vGeoAddressJson,
geoLatitude: v.string(),
geoLongitude: v.string(),
}),
v.object({
type: v.literal("ticketing"),
ticketingInfo: vTicketingInfo,
}),
v.object({
type: v.literal("venue"),
geoAddressJson: vGeoAddressJson,
geoLatitude: v.string(),
geoLongitude: v.string(),
})
);
15 replies
CCConvex Community
Created by gabrielw on 1/6/2025 in #support-community
Filtering a many:many ENT Edge
will mark this as resolved
6 replies
CCConvex Community
Created by gabrielw on 1/6/2025 in #support-community
Filtering a many:many ENT Edge
brief update here: I solved this problem with an abstraction of the many:many edge (a new table), with a new property startAtinMsSinceEpoch, and two additional indeces (1 of them a compound index). This solution allows me to do a descending and ascending paginated sort on a moment in time that is not the default _created_at system field, but rather, the utc time of an event.
export const getPerformancesByTeamId = query({
args: {
teamId: v.id("teams"),
paginationOpts: paginationOptsValidator,
type: v.optional(v.union(v.literal("upcoming"), v.literal("past"))),
},
async handler(ctx, { teamId, paginationOpts, type }) {
if (type === "upcoming") {
return await ctx
.table("performances", "by_teamId_startAtInMsSinceEpoch", (q) =>
q.eq("teamId", teamId)
)
.filter((q) => q.gte(q.field("startAtInMsSinceEpoch"), Date.now()))
.paginate(paginationOpts)
.map(async (performance) => {
const event = await performance.edge("event");
if (event.imgStorageId) {
const imgUrl = await ctx.storage.getUrl(event.imgStorageId);
if (imgUrl) {
return { ...event, imgUrl };
}
}
});
} else {
return await ctx
.table("performances")
.order("desc", "startAtInMsSinceEpoch")
.filter((q) =>
q.and(
q.eq(q.field("teamId"), teamId),
q.lt(q.field("startAtInMsSinceEpoch"), Date.now())
)
)
.paginate(paginationOpts)
.map(async (performance) => {
const event = await performance.edge("event");
if (event.imgStorageId) {
const imgUrl = await ctx.storage.getUrl(event.imgStorageId);
if (imgUrl) {
return { ...event, imgUrl };
}
}
});
}
},
});
export const getPerformancesByTeamId = query({
args: {
teamId: v.id("teams"),
paginationOpts: paginationOptsValidator,
type: v.optional(v.union(v.literal("upcoming"), v.literal("past"))),
},
async handler(ctx, { teamId, paginationOpts, type }) {
if (type === "upcoming") {
return await ctx
.table("performances", "by_teamId_startAtInMsSinceEpoch", (q) =>
q.eq("teamId", teamId)
)
.filter((q) => q.gte(q.field("startAtInMsSinceEpoch"), Date.now()))
.paginate(paginationOpts)
.map(async (performance) => {
const event = await performance.edge("event");
if (event.imgStorageId) {
const imgUrl = await ctx.storage.getUrl(event.imgStorageId);
if (imgUrl) {
return { ...event, imgUrl };
}
}
});
} else {
return await ctx
.table("performances")
.order("desc", "startAtInMsSinceEpoch")
.filter((q) =>
q.and(
q.eq(q.field("teamId"), teamId),
q.lt(q.field("startAtInMsSinceEpoch"), Date.now())
)
)
.paginate(paginationOpts)
.map(async (performance) => {
const event = await performance.edge("event");
if (event.imgStorageId) {
const imgUrl = await ctx.storage.getUrl(event.imgStorageId);
if (imgUrl) {
return { ...event, imgUrl };
}
}
});
}
},
});
6 replies
CCConvex Community
Created by gabrielw on 1/6/2025 in #support-community
Filtering a many:many ENT Edge
No description
6 replies
CCConvex Community
Created by ampp on 3/28/2024 in #support-community
ent filtering
Thanks @erquhart , I opened up a support post
50 replies
CCConvex Community
Created by ampp on 3/28/2024 in #support-community
ent filtering
Hey just circling back to this thread - having a similar issue with filtering an edge with ents. I am on convex-ents@latest and Typescript 5.7. here is my query:
export const getEventsByTeamId = query({
args: {
teamId: v.id("teams"),
paginationOpts: paginationOptsValidator,
status: vEventStatus,
},
async handler(ctx, { teamId, paginationOpts, status }) {
return await ctx
.table("teams")
.getX(teamId)
.edge("events")
.filter((q) => q.eq(q.field("status"), status))
.order("asc", "startAtInMsSinceEpoch")
.paginate(paginationOpts);
},
});
export const getEventsByTeamId = query({
args: {
teamId: v.id("teams"),
paginationOpts: paginationOptsValidator,
status: vEventStatus,
},
async handler(ctx, { teamId, paginationOpts, status }) {
return await ctx
.table("teams")
.getX(teamId)
.edge("events")
.filter((q) => q.eq(q.field("status"), status))
.order("asc", "startAtInMsSinceEpoch")
.paginate(paginationOpts);
},
});
The .filter is throwing a Type Error: Parameter 'q' implicitly has an 'any' type. Thanks all.
50 replies
CCConvex Community
Created by gabrielw on 12/23/2024 in #support-community
Hey all, does anyone know if there is a Table helper equivalent for convex ENTs?
ah thanks @deen . 🔥 I was curious about this pattern, since I saw elsewhere on discord that it was recommended to collocate all api functions in a single file, like an events.ts, instead of separate queries/mutations files. And so with this pattern, I found myself declaring validators, and also exporting the convex function handlers. I suppose the ents do introduce an additional abstraction that should be reflected at the filesystem level (ie, the tree-like structure). So I will nest something like a validators.ts and handlers.ts file within an events folder for example, and this should both resolve the type errors and organize the code nicely.
25 replies
CCConvex Community
Created by gabrielw on 1/1/2025 in #support-community
Convex Helpers build errors
yeah, I changed the target on my compilerOptions from "es" to "es2015" and am now building successfully. Heres the rest of my tsconfig now - |
{
"compilerOptions": {
"target": "es2015",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
{
"compilerOptions": {
"target": "es2015",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
5 replies
CCConvex Community
Created by gabrielw on 12/23/2024 in #support-community
Hey all, does anyone know if there is a Table helper equivalent for convex ENTs?
Thanks @deen , in regards to collocating validtors within different files, and importing them into the schema, I seem to be having some Uncaught TypeErrors when I try to export validators say from an events.ts file, into the schema.ts. I have my defineEnt args all within the schema.ts , just trying to collocate the validators. Interestingly, when I declare the validators within the schema.ts file, I am able to use them within the ent definitions without issues. Is this something you came accross?
25 replies
CCConvex Community
Created by gabrielw on 12/23/2024 in #support-community
Hey all, does anyone know if there is a Table helper equivalent for convex ENTs?
this all makes sense - I like your approach. Thanks for clarifying and for the example! Appreciate it.
25 replies
CCConvex Community
Created by gabrielw on 12/20/2024 in #support-community
Http referrers in google console via convex actions
Ah super helpful! Thanks Tom! Cheers
5 replies