gabrielw
gabrielw
CCConvex Community
Created by gabrielw on 1/6/2025 in #support-community
Filtering a many:many ENT Edge
Hey all, having some issues with filtering an edge with ents. I am on convex-ents@latest, Typescript 5.7 and convex 1.13.2. 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 q argument in the filter is throwing a Type Error: Parameter 'q' implicitly has an 'any' type. When I apply the filter on the "teams" table, the type inference is working as expected, but not when traversing the many:many edge. Here is a more detailed error on the actual filter, it seems like the filter is trying to read a Team document, and not the Event edge.
Property 'filter' does not exist on type 'PromiseEdgeEnts<EntDataModelFromSchema<SchemaDefinition<{ teams: EntDefinition<VObject<{ name: string; isPersonal: boolean; slug: string; deletionTime?: number | undefined; }, { name: VString<string, "required">; isPersonal: VBoolean<boolean, "required">; FieldName: never; }, "required", "name" |
Property 'filter' does not exist on type 'PromiseEdgeEnts<EntDataModelFromSchema<SchemaDefinition<{ teams: EntDefinition<VObject<{ name: string; isPersonal: boolean; slug: string; deletionTime?: number | undefined; }, { name: VString<string, "required">; isPersonal: VBoolean<boolean, "required">; FieldName: never; }, "required", "name" |
Thanks all.
6 replies
CCConvex Community
Created by gabrielw on 1/1/2025 in #support-community
Convex Helpers build errors
Hey happy new year all, I recently updated my convex-helpers npm package to the latest version (0.1.67), and have been working off of the convex sass starter repo. I seem to be getting the Type error when running yarn build:
./node_modules/convex-helpers/index.ts:16:22
Type error: Type 'Iterable<FromType>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.

14 | let index = 0;
15 | list = await list;
> 16 | for (const item of list) {
| ^
17 | promises.push(asyncTransform(item, index));
18 | index += 1;
19 | }
error Command failed with exit code 1.
./node_modules/convex-helpers/index.ts:16:22
Type error: Type 'Iterable<FromType>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.

14 | let index = 0;
15 | list = await list;
> 16 | for (const item of list) {
| ^
17 | promises.push(asyncTransform(item, index));
18 | index += 1;
19 | }
error Command failed with exit code 1.
I am wondering if anyone might have any recommendations, or knowledge of any packages/modifications needed in order to resolve this. Currently using convex npm version 1.13.2. (Not sure if updating convex will cause other breaking changes). Thank you!
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?
Trying to see if it's possible to collocate validators with schema definitions using the ENTs abstraction. For example, I am currently using the defineEnts method to define a table in my schema:
events: defineEnt({
name: v.string(),
event_img_storage_id: v.optional(v.id("_storage")),
event_img_url: v.optional(v.string()),
})
.field("start_at", v.string(), { index: true })
.field("timezone", v.string())
.field("end_at", v.optional(v.string()))
.field("geo_address_json", v.optional(geo_address_json_validator))
.field("geo_latitude", v.optional(v.string()))
.field("geo_longitude", v.optional(v.string()))
.field("luma_event_id", v.optional(v.string()))
.edges("teams"),...
events: defineEnt({
name: v.string(),
event_img_storage_id: v.optional(v.id("_storage")),
event_img_url: v.optional(v.string()),
})
.field("start_at", v.string(), { index: true })
.field("timezone", v.string())
.field("end_at", v.optional(v.string()))
.field("geo_address_json", v.optional(geo_address_json_validator))
.field("geo_latitude", v.optional(v.string()))
.field("geo_longitude", v.optional(v.string()))
.field("luma_event_id", v.optional(v.string()))
.edges("teams"),...
And I am exporting a separate obj in order to infer argument validation for the corresponding create mutation:
// supplied for frontend mutation
export const eventFields = {
name: v.string(),
start_at: v.string(),
timezone: v.string(),
end_at: v.optional(v.string()),
geo_address_json: v.optional(geo_address_json_validator),
geo_latitude: v.optional(v.string()),
geo_longitude: v.optional(v.string()),
team_ids: v.array(v.id("teams")),
event_img_storage_id: v.optional(v.id("_storage")),
};
// supplied for frontend mutation
export const eventFields = {
name: v.string(),
start_at: v.string(),
timezone: v.string(),
end_at: v.optional(v.string()),
geo_address_json: v.optional(geo_address_json_validator),
geo_latitude: v.optional(v.string()),
geo_longitude: v.optional(v.string()),
team_ids: v.array(v.id("teams")),
event_img_storage_id: v.optional(v.id("_storage")),
};
Just wondering if there is a way to declare the validator once and feed it into the schema with the ENT-way of doing things. As outlined in the best practices of not redefining the shape in vanilla convex:
// in convex/schema.ts
// ...
export const recipeFields = {
name: v.string(),
course: courseValidator,
ingredients: v.array(v.string()),
steps: v.array(v.string()),
};

export default defineSchema({
recipes: defineTable(recipeFields)
.index("by_course", ["course"]),
});
// in convex/schema.ts
// ...
export const recipeFields = {
name: v.string(),
course: courseValidator,
ingredients: v.array(v.string()),
steps: v.array(v.string()),
};

export default defineSchema({
recipes: defineTable(recipeFields)
.index("by_course", ["course"]),
});
25 replies
CCConvex Community
Created by gabrielw on 12/20/2024 in #support-community
Http referrers in google console via convex actions
Hey all, I am currently interacting with a google api (timezone api) and am configuring the website restrictions in the google console. My system environment variable referenced within the action is logging the expected value, accessed at process.env.CONVEX_CLOUD_URL. I've followed the guidelines in the google documentation to allow subdomains of convex.cloud to call the api from the server deployments, and have also added a referer to the headers of the fetch request made from the action. I'm wondering if anyone's faced a similar issue trying to add website restrictions in the google console for requests coming from the convex cloud urls, and if these should be treated in the same manner as requests being made from a front end client
5 replies
CCConvex Community
Created by gabrielw on 7/24/2024 in #show-and-tell
Working on Bandlink, https://www.bandlink.link/saturday_forever
This morning I deployed my convex env to prod and created the first profile. Been learning a ton, so far been having an absolute blast, and hoping to onboard some friends this week. The convex helpers have been super helpful for the more complex db lookups https://www.bandlink.link/saturday_forever
3 replies