DCsan
CCConvex Community
•Created by DCsan on 6/26/2023 in #support-community
helper queries?
I find myself writing a lot of boilerplate helper queries for every class like this.
are there any higher level methods for doing this?
eg I don't know the internal
_id
but i have my own IDs for tracking relations across tables.
I would like to have my own baseClass for the data tables and just extend to add these common repetitive methods but not sure where/if I can do that.
convex is nice that it's all JS, but it doesn't have the convenience of an actual ORM
6 replies
CCConvex Community
•Created by DCsan on 6/26/2023 in #support-community
virtual / calculated fields
I'm not sure if Convex really has model classes, but is there a way to extend a schema/model with something like virtual fields?
canonical example is you have first, last name fields and want a fullName that just concats them.
In my data model, it more just seems pure objects and I'm not even sure if there are underlying classes that I could patch methods onto that can look into the data of the object.
19 replies
CCConvex Community
•Created by DCsan on 6/26/2023 in #support-community
pattern for handling failed TXs
if i have a DB mutation that fails, eg buying something but the user doesn't have enough balance... is there a simple way to handle this?
eg can a
useMutation
return a value?
should I 'throw' inside the mutation fn and then catch in the main client code?
what other options are there?
I'd prefer to avoid something like a totally different out-of-band "errors" list9 replies
CCConvex Community
•Created by DCsan on 6/26/2023 in #support-community
better logging / debug output
is there a way to view better debug output?
ie formatted json objects?
It gets really hard having to manually decode the output I see like:
12 replies
CCConvex Community
•Created by DCsan on 6/25/2023 in #support-community
Argument of type 'unknown' is not assignable to parameter of type 'Id<string>'.
The basic tutorials don't work with typescript. eg
https://docs.convex.dev/functions/query-functions#query-arguments-and-responses
when I try to make a query that takes params, in typescript, eg like this:
I get this error:
Argument of type 'unknown' is not assignable to parameter of type 'Id<string>'.
how do i pass params to a query in a way that compiles?7 replies
CCConvex Community
•Created by DCsan on 6/13/2023 in #support-community
subscribe
I'm trying to use this as a realtime DB (firebase replacement) on the SERVER to listen to events.
How do i listen for changes on a collection, or subscribe to a query?
A bit like useQuery hook but for server side?
Or do I have to resort to something with actions?
33 replies
CCConvex Community
•Created by DCsan on 6/13/2023 in #support-community
typescript and src/
just getting started with adding to a TS project and stuck right away
when I run
npx convex dev
it creates a convex/_generated in the root level of my project.
Instead i keep all my TS code in src/
I tried adding a symlink inside src/convex to the root level _generated
but getting:
(the convex dev script is running)
is there some other magic I have to set?
I note there's also a tsconfig inside the convex dir, with
I wonder if that will conflict with the rest of my app?
also noting the .js files are side by side in the convex output, whereas I usually build all to /dist
before deploying.
using /src
and /dist
is fairly standard for a TS project, so maybe I'm missing something why I can't get started10 replies