Pietro
Pietro
CCConvex Community
Created by Pietro on 1/16/2024 in #support-community
Trigger/onUpdate Functions
I'd love to have Trigger functions (in addition to scheduled) : functions that are executed when a query returns. Similar to having a service that runs new Convexclient().onUpdate(query) but that actually runs "inside convex. I'm aware of the schedule.runAt(0...) pattern which is also nice, but I think the trigger pattern is more expressive, allowing muliple paralel behaviors to occur independently, and allows better modelling of fail scenarios and keeps the mutations cleaner. Also, I cant implement onUpdate patterns in for example vercel functions, having this would allow me to stay reactive withouth the burden of a stateful server. Usecase: I have datapoints being created in a table, with multiple mutations, from multiple sources and I want to model multiple parallel background job/queue that are triggered as soon as possible bc they are user facing. Cron not ideal because "asap" not "later".
23 replies
CCConvex Community
Created by Pietro on 1/16/2024 in #support-community
Large Tables
Hi I'm trying to import a CSV that has 3M rows (crunchbase basic csv) for a lookup usecase I was looking forward to. Basically an Algolia/Redis type experience with the convenience of convex. I chunked it into 100k rows each file but it still fails with a 408 : npx convex import --table cb_basic_org 01.csv --replace ✖ Importing data from "../DATA/crunchbase_basic/01.csv" to table "cb_organizations" failed 408 Request Timeout 1. Is it a bad idea to have a 2-3Gb csv dataset as a single table for a algolia style experience? 2. What is the optimal batch size to avoid these fails? 3. I'm doing this in DEV but seems like an overkill to keep loading this data for every preview, I'd rather have a PROD table with this which I refer to in DEV but I realize that a convex app only can point to a single endpoint. Should I load the data to PROD and then "replicate" the environment to DEV to avoid having to load the data twice? how should I think about this? 4. Do I understand correctly that each row is considered at least 1k for the purpose of quotas (so I should try to keep long tables around but under 1k per row for maximum cost efficiency?) Thanks P.
10 replies
CCConvex Community
Created by Pietro on 1/9/2024 in #support-community
Prefix Search requires v1.7 or greater
Prefix search doesn't seem to work for me, still catching full words only... not suitable for type ahead cases. Do I need to push some button or reset my DB or something for this to work? I get 0 hits until type the first full word... this is a Development environment that was running before the upgrade. I've ran npm convex dev etc. Thanks in advance for any tips.
person: defineTable({
name: v.string(),

}).searchIndex("person_by_name_2", { searchField: "name" }),
person: defineTable({
name: v.string(),

}).searchIndex("person_by_name_2", { searchField: "name" }),
export const get = query({
args: {
query: v.string(),
},
handler: async (ctx, args) => {
const x = await ctx.db
.query("person")
.withSearchIndex("person_by_name_2", (q) => q.search("name", args.query))
.take(5);
console.log("get: ", args.query, " - ", x?.length);

return x;
},
});
export const get = query({
args: {
query: v.string(),
},
handler: async (ctx, args) => {
const x = await ctx.db
.query("person")
.withSearchIndex("person_by_name_2", (q) => q.search("name", args.query))
.take(5);
console.log("get: ", args.query, " - ", x?.length);

return x;
},
});
5 replies
CCConvex Community
Created by Pietro on 12/8/2023 in #support-community
CLI: pull schema for dual projects same DB.
My project has a separation of frontend and backend node apps. My frontend atm is controlling the schema and functions but I'd like the backend (lets assume a separate repo) to be able to interact with the same db / schema with the same Developer experience. when I run npx convex dev on the backend the _convex folder gets generated but the api. does not auto complete. Is there a way to do something like npx convex pull schema and functions to update the schema locally and get the right DX on repos that are not the primary controlers of the code? thanks. P.
4 replies
CCConvex Community
Created by Pietro on 12/6/2023 in #support-community
Server side Query observer
Hi is it possible to create a server side application that is also reactive to simulate a Pub/Sub type setup? I understand that the React API under the hood must be doing this (connecting my node to your socket or something and get notified) but I could not figure out on the docs. Or is the right way to poll the api/query endpoint? or perhaps the watch endpoint (which I'd love to see an example of). Thanks P.
5 replies