woofwoof
woofwoof
CCConvex Community
Created by woofwoof on 10/30/2023 in #support-community
index order not as expected
Hey gang. I am building a table with sort functionality but am running into an issue the ordering. here is the exact code: let sortedBlockAttributes = await ctx.db .query("block_attributes") // adding the group attribute and value to the index below orders the results relative to // the sort. We don't need to add a value to them because we only care about the order. .withIndex( "by_parent_group_id_organization_id_group_attribute_id_value", (q: any) => q // @ts-ignore .eq("parent_group_id", args.rows) // limiting block_attributes to ones with a corisponding parent_group_id prevents timeouts .eq("organization_id", primaryGroup.organization_id) ) //@ts-ignore .order(args.sort?.[0]?.direction || "asc") .take(12000); blockIds = sortedBlockAttributes.map((ba) => bs.parent_block_id) } here is the schema for the "block_attributes" table: block_attributes: defineTable({ organization_id: v.id("organizations"), group_attribute_id: v.id("group_attributes"), parent_group_id: v.id("groups"), parent_block_id: v.id("blocks"), value: v.any(), meta: v.optional(v.any()), }) .index("by_parent_group_id_organization_id_group_attribute_id_value", [ "parent_group_id", "organization_id", "group_attribute_id", "value", ]) Provided a parent_group_id and an organization_id, this code is intended to return all rows in a convex table sorted by value (in this example all entries int he tabel have the same group_attribute_id)... however the results (a list of Unix epoch time stamps) come back out of order. I have been up all night trying to get this to work so there is a > 0 chance I am just doing something dumb. Either way I would love some advice from a more experienced/well rested brain lol
3 replies
CCConvex Community
Created by woofwoof on 9/30/2023 in #support-community
"Log line is too long" on seemingly simple query on small table.
Hey gang! Our team is absolutely loving building on top of convex. We are actually in the process of moving our entire application/business onto the platform. I am having an unusual issue though today. Out of seemingly nowhere (said every developer ever) a function that was working has stopped. I traced it down to the following query but cannot figure out what the issues is. const ga = await ctx.db.query("group_attributes").take(16); and here is the "group_attributes" table schema: group_attributes: defineTable({ organization_id: v.id("organizations"), name: v.string(), parent_group_id: v.id("groups"), ref_group_id: v.optional(v.id("groups")), type: v.string(), meta: v.optional(v.any()), }).index("by_organization_id_parent_group_id", [ "organization_id", "parent_group_id", ]), I have stripped verything else out of the parent funciton to the above query and even stripped the query down to its most basic form (removed indexes then filters to just "take" becasue collect() was erroring out). The query works if take is set to 15 but errors out for anything greater. The corresponding "group_attriubtes" table only has 97 documents in it so I have a hard time seeing how this could be timeout related. Plus, putting other queries before it in the function (which would theoretically decrease the time available to run the query) do not effect the take(15) cutoff. The query shows the following error in the convex logs: failure Uncaught Error: Log line is too long (4224 > maximum length 4096) at handler (../convex/blocks.ts:47:11) I have been troubleshooting this all morning and it's starting to push other tasks back... so naturally I figured I would ask the experts.
4 replies
CCConvex Community
Created by woofwoof on 8/28/2023 in #support-community
Trouble with getUserIdentity(), Auth0 and Next.js
No description
22 replies