zoomie
zoomie
CCConvex Community
Created by zoomie on 3/15/2025 in #support-community
Can't apply multiple bounds (filters) on an index
For the table I'm filtering, I don't know how many results I will get back. I don't want to use collect (in case it crashes) and if I use take, their is a chance all the data returned will be filtered out and the user won't see anything. I thought I'd add all the filter options into the index, but get an error.
// transaction.ts
.withIndex("by_project_id_and_block_timestamp_and_value_quote", (q) =>
q
.eq("project_id", projectId)
.gte("block_timestamp", startDate)
.lte("block_timestamp", endDate)
.gte("value_quote", minAmount)
)

// schema.ts
.index("by_project_id_and_block_timestamp_and_value_quote", [
"project_id",
"block_timestamp",
"value_quote",
])
// transaction.ts
.withIndex("by_project_id_and_block_timestamp_and_value_quote", (q) =>
q
.eq("project_id", projectId)
.gte("block_timestamp", startDate)
.lte("block_timestamp", endDate)
.gte("value_quote", minAmount)
)

// schema.ts
.index("by_project_id_and_block_timestamp_and_value_quote", [
"project_id",
"block_timestamp",
"value_quote",
])
Error: Property 'gte' does not exist on type 'IndexRange'. Is their a way to use an and? It looks like you can only apply one UpperBoundIndexRangeBuilder and LowerBoundIndexRangeBuilder
6 replies
CCConvex Community
Created by zoomie on 5/7/2024 in #support-community
Select specific db columns on server (bytes execution limit)
The following code in convex/lead.ts:
const leads = await ctx.db.query("lead").collect();
const mapLeads = leads.map((lead) => {
return {_id: lead._id, latitude: lead.latitude,longitude: lead.longitude,};
});
const leads = await ctx.db.query("lead").collect();
const mapLeads = leads.map((lead) => {
return {_id: lead._id, latitude: lead.latitude,longitude: lead.longitude,};
});
Uncaught Error: Too many bytes read in a single function execution (limit: 8388608 bytes). Consider using smaller limits in your queries, paginating your queries, or using indexed queries with a selective index range expressions.
Uncaught Error: Too many bytes read in a single function execution (limit: 8388608 bytes). Consider using smaller limits in your queries, paginating your queries, or using indexed queries with a selective index range expressions.
Is it possible to select only the columns (fields) I want in the db query? An SQL analogy would be:
SELECT _id, latitude, longitude FROM lead
SELECT _id, latitude, longitude FROM lead
8 replies
CCConvex Community
Created by zoomie on 5/6/2024 in #support-community
Partial schema
Is it possible to have a partial schema? I have a table called lead with data in it. The schema is lead: defineTable(v.any()). I want to add an index, so I need to define the fields.
lead: defineTable({
latitude: v.optional(v.number()),
longitude: v.optional(v.number()),
})
lead: defineTable({
latitude: v.optional(v.number()),
longitude: v.optional(v.number()),
})
As there is existing data in the table, I'm getting this error:
Document with ID ... in table "lead" does not match the schema: Object contains extra field that is not in the validator.
Document with ID ... in table "lead" does not match the schema: Object contains extra field that is not in the validator.
13 replies
CCConvex Community
Created by zoomie on 4/18/2024 in #support-community
csv loader (without convex mutation)
I'm trying to make a general csv loader, is there a way to do this without needing to write a mutation? The following comment is how I imagine it should work // Script loads a csv file into an empty convex table. // Create a new table in convex, pass this name as <table_name>. // It uses the names of the csv file columns as the column names in the table. // Usage: node scripts/load_csv.js <table_name> <csv_file_path>
3 replies